﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using SystemModule;

namespace M2Server
{
    public partial class TPlayObject
    {
        /// <summary>
        /// 发送登录
        /// </summary>
        private  void SendLogon()
        {
            TMessageBodyWL MessageBodyWL = new TMessageBodyWL();
            int nRecog;
            this.m_DefMsg = EncryptUnit.MakeDefaultMsg(Grobal2.SM_LOGON, this.m_ActorsId, this.m_nCurrX, this.m_nCurrY,
                (short)HUtil32.MakeWord((byte)this.m_btDirection, (byte)this.m_nLight), 0);
            MessageBodyWL.lParam1 = this.GetFeatureToLong();// 人物着装
            MessageBodyWL.lParam2 = this.m_nCharStatus;// 人物状态
            MessageBodyWL.lParam3 = this.GetFeatureJob();//JOB等等属性
            m_boAllowGroup = false;//人物上线自动关组
            MessageBodyWL.lTag1 = 0;
            MessageBodyWL.lTag2 = 0;
            nRecog = this.GetFeatureToLong();
            SendSocket(this.m_DefMsg, EncryptUnit.EncodeBuffer(MessageBodyWL));
            SendDefMessage(Grobal2.SM_FEATURECHANGED, this.m_ActorsId, nRecog, nRecog, this.GetFeatureEx(), "");
        }

        /// <summary>
        /// 发送游戏公告
        /// </summary>
        private  void SendNotice()
        {
            List<string> LoadList;
            string sNoticeMsg = string.Empty;
            LoadList = new List<string>();
            M2Share.NoticeManager.GetNoticeMsg("Notice", LoadList);
            if (LoadList.Count > 0)
            {
                for (int i = 0; i < LoadList.Count; i++)
                {
                    sNoticeMsg = sNoticeMsg + LoadList[i] + "\x20\x1B";
                }
            }
            Dispose(LoadList);
            SendDefMessage(Grobal2.SM_SENDNOTICE, 2000, 0, 0, 0, sNoticeMsg.ToString().Replace("/r/n/r/n ", ""));
        }

        /// <summary>
        /// 人物登录游戏
        /// </summary>
        public virtual void UserLogon()
        {
            TUserItem UserItem = null;
            TUserItem UserItem1 = null;
            TStdItem StdItem;
            string s14;
            string sItem;
            string sIPaddr;
            int n08;
            int n09;
            byte nCode;
            TUserMagic UserMagic;
            const string sExceptionMsg = "[异常] TPlayObject::UserLogon";
            const string sCheckIPaddrFail = "登录IP地址不匹配！！！";
            sIPaddr = "";
            nCode = 0;
            try
            {
                if (M2Share.g_Config.boTestServer)
                {
                    nCode = 1;
                    if (this.m_Abil.Level < M2Share.g_Config.nTestLevel)
                    {
                        this.m_Abil.Level = M2Share.g_Config.nTestLevel;
                    }
                    if (this.m_nGold < M2Share.g_Config.nTestGold)
                    {
                        this.m_nGold = M2Share.g_Config.nTestGold;
                    }
                }
                nCode = 2;
                if (M2Share.g_Config.boTestServer || (M2Share.g_Config.boServiceMode))
                {
                    m_nPayMent = 3;
                }
                this.m_dwMapMoveTick = HUtil32.GetTickCount();
                this.m_dLogonTime = DateTime.Now;
                this.m_dwLogonTick = HUtil32.GetTickCount();
                nCode = 3;
                this.Initialize();//初始化
                nCode = 4;
                this.SendMsg(this, Grobal2.RM_LOGON, 0, 0, 0, 0, "");
                nCode = 5;
                if (this.m_Abil.Level <= 7)
                {
                    if (GetRangeHumanCount() >= 80)
                    {
                        this.MapRandomMove(this.m_PEnvir.sMapName, 0);
                    }
                }
                if (m_boDieInFight3Zone)
                {
                    this.MapRandomMove(this.m_PEnvir.sMapName, 0);
                }
                nCode = 6;
                if (M2Share.UserEngine.GetHumPermission(this.m_sCharName, ref sIPaddr, ref this.m_btPermission))// 取人物权限值
                {
                    if (!string.IsNullOrEmpty(sIPaddr))
                    {
                        if (!M2Share.CompareIPaddr(m_sIPaddr, sIPaddr))
                        {
                            this.SysMsg(sCheckIPaddrFail, TMsgColor.c_Red, TMsgType.t_Hint);
                            m_boEmergencyClose = true;
                            m_boPlayOffLine = false;
                        }
                    }
                }
                nCode = 7;
                GetStartPoint();
                nCode = 8;
                for (int i = 0; i < this.m_MagicList.Count; i++)
                {
                    if (this.m_MagicList.Count <= 0)
                    {
                        break;
                    }
                    if ((this.m_MagicList[i]) != null)
                    {
                        this.sub_4C713C((this.m_MagicList[i]));
                    }
                }
                nCode = 9;
                if (m_boNewHuman)// 给新人增加新人物品
                {
                    UserItem = new TUserItem();
                    if (M2Share.UserEngine.CopyToUserItemFromName(M2Share.g_Config.sCandle, UserItem))
                    {
                        this.m_ItemList.Add(UserItem);
                    }
                    else
                    {
                        UserItem = null;
                    }
                    UserItem = new TUserItem();
                    if (M2Share.UserEngine.CopyToUserItemFromName(M2Share.g_Config.sBasicDrug, UserItem))
                    {
                        this.m_ItemList.Add(UserItem);
                    }
                    else
                    {
                        UserItem = null;
                    }
                    UserItem = new TUserItem();
                    if (M2Share.UserEngine.CopyToUserItemFromName(M2Share.g_Config.sWoodenSword, UserItem))
                    {
                        this.m_ItemList.Add(UserItem);
                    }
                    else
                    {
                        UserItem = null;
                    }
                    if (this.m_btGender == 0) //性别 0 男 1女
                    {
                        sItem = M2Share.g_Config.sClothsMan;
                    }
                    else
                    {
                        sItem = M2Share.g_Config.sClothsWoman;
                    }
                    UserItem = new TUserItem();
                    if (M2Share.UserEngine.CopyToUserItemFromName(sItem, UserItem))
                    {
                        this.m_ItemList.Add(UserItem);
                    }
                    else
                    {
                        UserItem = null;
                    }
                }
                nCode = 10;
                // 检查背包中的物品是否合法
                for (int i = this.m_ItemList.Count - 1; i >= 0; i--)
                {
                    if (this.m_ItemList.Count <= 0)
                    {
                        break;
                    }
                    UserItem = this.m_ItemList[i];
                    if (UserItem != null)
                    {
                        if ((M2Share.UserEngine.GetStdItemName(UserItem.wIndex) == "")
                            || (UserItem.MakeIndex < 0)//增加，判断制造ID是否为负数
                            || this.CheckIsOKItem(UserItem, 0))// 检查变态物品
                        {
                            M2Share.MainOutMessage("[登录清包裹非法物品](" + this.m_sCharName + ")" + M2Share.UserEngine.GetStdItemName(UserItem.wIndex) + "("
                                + (UserItem.MakeIndex).ToString() + ")[" + (UserItem.btValue[0]).ToString() + "/" + (UserItem.btValue[1]).ToString() + "/"
                                + (UserItem.btValue[2]).ToString() + "/" + (UserItem.btValue[3]).ToString() + "/" + (UserItem.btValue[4]).ToString() + "/"
                                + (UserItem.btValue[5]).ToString() + "/" + (UserItem.btValue[6]).ToString() + "/" + (UserItem.btValue[7]).ToString() + "/"
                                + (UserItem.btValue[8]).ToString() + "/" + (UserItem.btValue[14]).ToString() + "/#" + (UserItem.btValue[15]).ToString()
                                + "/" + (UserItem.btValue[16]).ToString() + "/" + (UserItem.btValue[17]).ToString() + "/" + (UserItem.btValue[18]).ToString()
                                + "/" + (UserItem.btValue[19]).ToString()); // 记录清除非法物品信息
                            Dispose(this.m_ItemList[i]);
                            this.m_ItemList.RemoveAt(i);
                        }
                    }
                }
                nCode = 11;
                // 检查人物身上的物品是否符合使用规则
                if (M2Share.g_Config.boCheckUserItemPlace)
                {
                    for (int i = m_UseItems.GetLowerBound(0); i <= m_UseItems.GetUpperBound(0); i++)
                    {
                        if (this.m_UseItems[i] != null && this.m_UseItems[i].wIndex > 0)
                        {
                            StdItem = M2Share.UserEngine.GetStdItem(this.m_UseItems[i].wIndex);
                            if (StdItem != null)
                            {
                                if (this.CheckIsOKItem(this.m_UseItems[i], 0))  // 检查变态物品
                                {
                                    this.m_UseItems[i].wIndex = 0;
                                    continue;
                                }
                                if (!M2Share.CheckUserItems(i, StdItem))
                                {
                                    UserItem = this.m_UseItems[i];
                                    if (!this.AddItemToBag(UserItem))
                                    {
                                        this.m_ItemList.Insert(0, UserItem);
                                    }
                                    this.m_UseItems[i].wIndex = 0;
                                }
                            }
                            else
                            {
                                this.m_UseItems[i].wIndex = 0;
                            }
                        }
                    }
                }
                nCode = 12;
                for (int i = this.m_ItemList.Count - 1; i >= 0; i--) // 检查背包中是否有复制品
                {
                    if (this.m_ItemList.Count <= 0)
                    {
                        break;
                    }
                    UserItem = this.m_ItemList[i];
                    if (UserItem != null)
                    {
                        s14 = M2Share.UserEngine.GetStdItemName(UserItem.wIndex);
                        for (int k = i - 1; k >= 0; k--)
                        {
                            UserItem1 = (TUserItem)this.m_ItemList[k];
                            if ((M2Share.UserEngine.GetStdItemName(UserItem1.wIndex) == s14) && (UserItem.MakeIndex == UserItem1.MakeIndex))
                            {
                                M2Share.MainOutMessage("[登录清包裹复制品](" + this.m_sCharName + ")" + s14 + "(" + UserItem1.MakeIndex + ")");//记录清除复制品信息
                                this.m_ItemList.RemoveAt(k);
                                break;
                            }
                        }
                    }
                }
                nCode = 13;
                for (int i = this.m_dwStatusArrTick.GetLowerBound(0); i <= this.m_dwStatusArrTick.GetUpperBound(0); i++)
                {
                    if (this.m_wStatusTimeArr[i] > 0)
                    {
                        this.m_dwStatusArrTick[i] = HUtil32.GetTickCount();
                    }
                }
                nCode = 14;
                this.m_nCharStatus = this.GetCharStatus();
                this.RecalcLevelAbilitys();// 重新计算角色的等级各属性
                RecalcAbilitys(); // 刷新能力
                this.CompareSuitItem(true);// 套装与身上装备对比
                nCode = 15;
                this.m_Abil.MaxExp = this.GetLevelExp(this.m_Abil.Level);
                if (this.btB2 == 0)
                {
                    this.m_nPkPoint = 0;
                    this.btB2++;
                }
                nCode = 16;
                if ((this.m_nGold > M2Share.g_Config.nHumanMaxGold) && (M2Share.g_Config.nHumanMaxGold > 0))
                {
                    this.m_nGold = M2Share.g_Config.nHumanMaxGold;
                    if (this.m_nGold > int.MaxValue)
                    {
                        this.m_nGold = int.MaxValue;
                    }
                }
                if (this.m_nGold <= 0)
                {
                    this.m_nGold = 0;
                }
                if (!bo6AB)
                {
                    if ((m_nSoftVersionDate < M2Share.g_Config.nSoftVersionDate))// 对比客户端版本号
                    {
                        nCode = 17;
                        this.SysMsg(GameMsgDef.sClientSoftVersionError, TMsgColor.c_Red, TMsgType.t_Hint);
                        this.SysMsg(GameMsgDef.sDownLoadNewClientSoft, TMsgColor.c_Red, TMsgType.t_Hint);
                        this.SysMsg(GameMsgDef.sForceDisConnect, TMsgColor.c_Red, TMsgType.t_Hint);
                        m_boEmergencyClose = true;
                        m_boPlayOffLine = false;
                        return;
                    }
                    if ((m_nSoftVersionDateEx == 0))
                    {
                        if ((!M2Share.g_Config.boCanOldClientLogon)) // 如果不允许普通客户端登录,则退出
                        {
                            nCode = 18;
                            this.SysMsg(GameMsgDef.sClientSoftVersionError, TMsgColor.c_Red, TMsgType.t_Hint);
                            this.SysMsg(GameMsgDef.sDownLoadNewClientSoft, TMsgColor.c_Red, TMsgType.t_Hint);
                            this.SysMsg(GameMsgDef.sForceDisConnect, TMsgColor.c_Red, TMsgType.t_Hint);
                            m_boEmergencyClose = true;
                            m_boPlayOffLine = false;
                            return;
                        }
                        if (M2Share.g_Config.boOldClientShowHiLevel)
                        {
                            nCode = 19;
                            this.SysMsg(GameMsgDef.sClientSoftVersionTooOld, TMsgColor.c_Blue, TMsgType.t_Hint);
                            this.SysMsg(GameMsgDef.sDownLoadAndUseNewClient, TMsgColor.c_Red, TMsgType.t_Hint);
                        }
                    }
                    nCode = 20;
                    switch (this.m_btAttatckMode)
                    {
                        case M2Share.HAM_ALL://加入聊天框中提示
                            this.SendMsg(this, Grobal2.RM_CHANGEATTATCKMODE, 0, 0, 0, 0, GameMsgDef.sAttackModeOfAll);// [攻击模式: 全体攻击]
                            this.SysMsg(GameMsgDef.sAttackModeOfAll, TMsgColor.c_Green, TMsgType.t_Hint);
                            break;
                        case M2Share.HAM_PEACE:// [攻击模式: 全体攻击]
                            this.SendMsg(this, Grobal2.RM_CHANGEATTATCKMODE, 0, 0, 0, 0, GameMsgDef.sAttackModeOfPeaceful);// [攻击模式: 和平攻击]
                            this.SysMsg(GameMsgDef.sAttackModeOfPeaceful, TMsgColor.c_Green, TMsgType.t_Hint);
                            break;
                        case M2Share.HAM_DEAR:// [攻击模式: 和平攻击]
                            this.SendMsg(this, Grobal2.RM_CHANGEATTATCKMODE, 0, 0, 0, 0, GameMsgDef.sAttackModeOfDear);// [攻击模式: 夫妻攻击]
                            this.SysMsg(GameMsgDef.sAttackModeOfDear, TMsgColor.c_Green, TMsgType.t_Hint);
                            break;
                        case M2Share.HAM_MASTER:// [攻击模式: 夫妻攻击]
                            this.SendMsg(this, Grobal2.RM_CHANGEATTATCKMODE, 0, 0, 0, 0, GameMsgDef.sAttackModeOfMaster);// [攻击模式: 师徒攻击]
                            this.SysMsg(GameMsgDef.sAttackModeOfMaster, TMsgColor.c_Green, TMsgType.t_Hint);
                            break;
                        case M2Share.HAM_GROUP:// [攻击模式: 师徒攻击]
                            this.SendMsg(this, Grobal2.RM_CHANGEATTATCKMODE, 0, 0, 0, 0, GameMsgDef.sAttackModeOfGroup);// [攻击模式: 编组攻击]
                            this.SysMsg(GameMsgDef.sAttackModeOfGroup, TMsgColor.c_Green, TMsgType.t_Hint);
                            break;
                        case M2Share.HAM_GUILD:// [攻击模式: 编组攻击]
                            this.SendMsg(this, Grobal2.RM_CHANGEATTATCKMODE, 0, 0, 0, 0, GameMsgDef.sAttackModeOfGuild);// [攻击模式: 行会攻击]
                            this.SysMsg(GameMsgDef.sAttackModeOfGuild, TMsgColor.c_Green, TMsgType.t_Hint);
                            break;
                        case M2Share.HAM_PKATTACK:// [攻击模式: 行会攻击]
                            this.SendMsg(this, Grobal2.RM_CHANGEATTATCKMODE, 0, 0, 0, 0, GameMsgDef.sAttackModeOfRedWhite);// [攻击模式: 红名攻击]
                            this.SysMsg(GameMsgDef.sAttackModeOfRedWhite, TMsgColor.c_Green, TMsgType.t_Hint);// [攻击模式: 红名攻击]
                            break;
                    }
                    this.SysMsg(GameMsgDef.sStartChangeAttackModeHelp, TMsgColor.c_Green, TMsgType.t_Hint); // 使用组合快捷键 CTRL-H 更改攻击...
                    nCode = 21;
                    if (m_dwKillMonExpRateTime > 0) // 双倍经验时间内,进入游戏提示
                    {
                        this.SysMsg(string.Format(GameMsgDef.g_sChangeKillMonExpRateMsg, m_nKillMonExpRate / 100, m_dwKillMonExpRateTime), TMsgColor.c_Green, TMsgType.t_Hint);
                    }
                    nCode = 22;
                    if (M2Share.g_Config.boTestServer)
                    {
                        this.SysMsg(GameMsgDef.sStartNoticeMsg, TMsgColor.c_Green, TMsgType.t_Hint); // 欢迎进入本服务器进行游戏...
                    }
                    if (M2Share.UserEngine.PlayObjectCount > M2Share.g_Config.nTestUserLimit)
                    {
                        if (this.m_btPermission < 2)
                        {
                            nCode = 23;
                            this.SysMsg(GameMsgDef.sOnlineUserFull, TMsgColor.c_Red, TMsgType.t_Hint);
                            this.SysMsg(GameMsgDef.sForceDisConnect, TMsgColor.c_Red, TMsgType.t_Hint);
                            m_boEmergencyClose = true;
                            m_boPlayOffLine = false;
                        }
                    }
                }
                nCode = 24;
                m_nBright = M2Share.g_nGameTime;
                this.m_Abil.MaxExp = this.GetLevelExp(this.m_Abil.Level);//登录重新取得升级所需经验值
                if (m_boTrainingNG)// 学过内功
                {
                    m_MaxExpSkill69 = this.GetSkill69Exp(m_NGLevel, ref m_Skill69MaxNH);// 登录重新取内功心法升级经验
                    this.SendNGData();
                }
                if (this.m_MagicList.Count > 0)
                {
                    for (int i = 0; i < this.m_MagicList.Count; i++)
                    {
                        UserMagic = this.m_MagicList[i];
                        if (UserMagic != null)
                        {
                            if (UserMagic.MagicInfo.sDescr == "连击")
                            {
                                this.m_boCanUseBatter = true;
                                break;
                            }
                        }
                    }
                }
                for (int i = 0; i <= 2; i++)
                {
                    n08 = this.m_nBatterOrder[i];
                    n09 = 0;
                    if ((n08 == 0) || (n08 == 2222))
                    {
                        continue;
                    }
                    if (this.m_MagicList.Count > 0)
                    {
                        for (int j = 0; j < this.m_MagicList.Count; j++)
                        {
                            UserMagic = this.m_MagicList[j];
                            if (UserMagic != null)
                            {
                                if ((UserMagic.MagicInfo.sDescr == "连击") && (UserMagic.MagicInfo.wMagicId == n08))
                                {
                                    this.m_boCanUseBatter = true;
                                    n09 = 8;
                                    break;
                                }
                            }
                        }
                    }
                    if (n09 != 8)
                    {
                        this.m_nBatterOrder[i] = 0; // 整理连击循序防止卡
                    }
                }
                nCode = 25;
                this.SendMsg(this, Grobal2.RM_ABILITY, 0, 0, 0, 0, "");
                this.SendMsg(this, Grobal2.RM_SUBABILITY, 0, 0, 0, 0, "");
                this.SendMsg(this, Grobal2.RM_ADJUST_BONUS, 0, 0, 0, 0, "");
                this.SendMsg(this, Grobal2.RM_DAYCHANGING, 0, 0, 0, 0, "");// 发送白天或晚上的状态
                this.SendMsg(this, Grobal2.RM_SENDUSEITEMS, 0, 0, 0, 0, "");// 发送使用的物品
                this.SendMsg(this, Grobal2.RM_SENDMYMAGIC, 0, 0, 0, 0, "");// 发送使用的魔法
                this.SendMsg(this, Grobal2.RM_PULSECHANGED, 0, 0, 0, 0, "");// 经络
                this.SendMsg(this, Grobal2.RM_BATTERORDER, 0, 0, 0, 0, "");// 连击技能循序
                this.SendMsg(this, Grobal2.RM_HEROATTECTMODE, 0, 0, 0, 0, "");// 副将英雄出战职业
                this.StormsRateChanged();
                this.OpenPulseNeedLevTabChanged();
                nCode = 26;
                if (m_MyHero != null)
                {
                    THeroObject HeroObject = ((THeroObject)(m_MyHero));
                    // 发送英雄信息 人物是离线挂机状态
                    this.SendDelayMsg(this, Grobal2.RM_RECALLHERO, 0, m_MyHero.m_ActorsId, 0, 0, "", 1000);
                    switch (HeroObject.m_btStatus)
                    {
                        case 1:
                            HeroObject.SysMsg(GameMsgDef.g_sHeroFollow, TMsgColor.c_Green, TMsgType.t_Hint);
                            break;
                        case 0:
                            HeroObject.SysMsg(GameMsgDef.g_sHeroAttack, TMsgColor.c_Green, TMsgType.t_Hint);
                            break;
                        case 2:
                            HeroObject.SysMsg(GameMsgDef.g_sHeroRest, TMsgColor.c_Green, TMsgType.t_Hint);
                            break;
                    }
                    HeroObject.SysMsg(GameMsgDef.g_sHeroLoginMsg, TMsgColor.c_Green, TMsgType.t_Hint);
                    if (HeroObject.m_nFirDragonPoint > M2Share.g_Config.nMaxFirDragonPoint)
                    {
                        HeroObject.m_nFirDragonPoint = M2Share.g_Config.nMaxFirDragonPoint; //防止怒气调整后超过
                    }
                    HeroObject.SendMsg(m_MyHero, Grobal2.RM_FIRDRAGONPOINT, M2Share.g_Config.nMaxFirDragonPoint, HeroObject.m_nFirDragonPoint, 0, 0, "");// 发送英雄怒气值
                }
                nCode = 27;
                this.m_MyGuild = M2Share.g_GuildManager.MemberOfGuild(this.m_sCharName);
                if (this.m_MyGuild != null)
                {
                    this.m_sGuildRankName = this.m_MyGuild.GetRankName(this, ref this.m_nGuildRankNo);
                    if (this.m_MyGuild.GuildWarList.Count > 0)
                    {
                        for (int i = 0; i < this.m_MyGuild.GuildWarList.Count; i++)
                        {
                            this.SysMsg(this.m_MyGuild.GuildWarList[i] + " 正在与本行会进行行会战。", TMsgColor.c_Green, TMsgType.t_Hint);
                        }
                    }
                }
                nCode = 28;
                this.RefShowName();
                if ((m_nPayMent == 1))
                {
                    if (!bo6AB)
                    {
                        this.SysMsg(GameMsgDef.sYouNowIsTryPlayMode, TMsgColor.c_Red, TMsgType.t_Hint);
                    }
                    nCode = 29;
                    this.m_nGoldMax = M2Share.g_Config.nHumanTryModeMaxGold;
                    if (this.m_Abil.Level > M2Share.g_Config.nTryModeLevel)
                    {
                        this.SysMsg("测试状态可以使用到第 " + (M2Share.g_Config.nTryModeLevel).ToString() + " 级。", TMsgColor.c_Red, TMsgType.t_Hint);
                        this.SysMsg("链接中断，请到以下地址获得相关信息。(http://mir.sdo.com)", TMsgColor.c_Red, TMsgType.t_Hint);
                        m_boEmergencyClose = true;
                        m_boPlayOffLine = false;
                    }
                }
                nCode = 30;
                if ((m_nPayMent == 3) && !bo6AB)
                {
                    this.SysMsg(GameMsgDef.g_sNowIsFreePlayMode, TMsgColor.c_Green, TMsgType.t_Hint);// '当前服务器运行于测试模式.'
                }
                if (M2Share.g_Config.boVentureServer)
                {
                    this.SysMsg("当前服务器运行于 不刷怪模式.", TMsgColor.c_Green, TMsgType.t_Hint);
                }
                if ((this.m_MagicArr[0][MagicConst.SKILL_ERGUM] != null) && (!this.m_boUseThrusting))
                {
                    this.m_boUseThrusting = true;
                    unsafe { SendSocket(null, "+LNG"); }
                }
                nCode = 31;
                if (this.m_PEnvir.m_boNORECONNECT)
                {
                    this.MapRandomMove(this.m_PEnvir.sNoReconnectMap, 0);
                }
                nCode = 32;
                if (CheckDenyLogon())// 如果人物在禁止登录列表里则直接掉线而不执行下面内容
                {
                    m_boEmergencyClose = true;//修正禁止人物登陆不下线的问题
                    m_boPlayOffLine = false;
                    return;
                }
                // ==============================人物超过限制踢下线===========================
                nCode = 33;
                if (M2Share.UserEngine.PlayObjectCount > M2Share.UserEngine.m_nLimitUserCount)
                {
                    if (this.m_btPermission < 10)
                    {
                        m_boPlayOffLine = false;
                        m_boEmergencyClose = true;
                        return;
                    }
                }
                // ==============================================================================
                nCode = 34;
                if (M2Share.g_ManageNPC != null)
                {
                    M2Share.g_ManageNPC.GotoLable(this, "@Login", false);
                }
                nCode = 35;
                this.m_boFixedHideMode = false;
                if (m_sDearName != "")
                {
                    CheckMarry();
                }
                CheckMaster();
                nCode = 36;
                m_boFilterSendMsg = M2Share.GetDisableSendMsgList(this.m_sCharName);
                nCode = 37;
                if (M2Share.g_Config.boPasswordLockSystem) // 密码保护系统
                {
                    if (m_boPasswordLocked)
                    {
                        m_boCanGetBackItem = !M2Share.g_Config.boLockGetBackItemAction;
                    }
                    nCode = 38;
                    if (M2Share.g_Config.boLockHumanLogin && m_boLockLogon && m_boPasswordLocked)
                    {
                        m_boCanDeal = !M2Share.g_Config.boLockDealAction;
                        m_boCanDrop = !M2Share.g_Config.boLockDropAction;
                        m_boCanUseItem = !M2Share.g_Config.boLockUserItemAction;
                        m_boCanWalk = !M2Share.g_Config.boLockWalkAction;
                        m_boCanRun = !M2Share.g_Config.boLockRunAction;
                        m_boCanHit = !M2Share.g_Config.boLockHitAction;
                        m_boCanSpell = !M2Share.g_Config.boLockSpellAction;
                        m_boCallHero = !M2Share.g_Config.boLockCallHeroAction;// 是否锁定召唤英雄操作 
                        m_boCanSendMsg = !M2Share.g_Config.boLockSendMsgAction;
                        this.m_boObMode = M2Share.g_Config.boLockInObModeAction;
                        nCode = 39;
                        this.SysMsg(GameMsgDef.g_sActionIsLockedMsg + " 开锁命令: @" + M2Share.g_GameCommand.UnLock.sCmd, TMsgColor.c_Red, TMsgType.t_Hint);
                        this.SendMsg(M2Share.g_ManageNPC, Grobal2.RM_MENU_OK, 0, this.m_ActorsId, 0, 0, GameMsgDef.g_sActionIsLockedMsg + "\\ \\" + "开锁命令: @"
                            + M2Share.g_GameCommand.UnLock.sCmd + "\\" + "加锁命令: @" + M2Share.g_GameCommand.__Lock.sCmd + "\\" + "设置密码命令: @"
                            + M2Share.g_GameCommand.SETPASSWORD.sCmd + "\\" + "修改密码命令: @" + M2Share.g_GameCommand.CHGPASSWORD.sCmd);
                    }
                }
                nCode = 40;// 重置泡点方面计时
                m_dwIncGamePointTick = HUtil32.GetTickCount();
                m_dwIncGameGoldTick = HUtil32.GetTickCount();
                m_dwAutoGetExpTick = HUtil32.GetTickCount();
                nCode = 31;
                GetSellOffGlod();// 检查是否有元宝寄售交易结束还没得到元宝
                nCode = 32;
                IsItem_51(1);// 发送聚灵珠的经验
                if ((this.m_btMagBubbleDefenceLevel == 4) && (this.m_dwStatusArrTick[Grobal2.STATE_BUBBLEDEFENCEUP] > 0))
                {
                    this.StatusChanged("444"); // 4级盾,发个消息给客户端显示特有的效果;
                }
            }
            catch
            {
                M2Share.MainOutMessage(sExceptionMsg + " Name:" + this.m_sCharName + "  Code:" + nCode);
            }
        }


        public override void Run()
        {
            int tObjCount;
            int nInteger = 0;
            TProcessMessage ProcessMsg = null;
            TPlayObject PlayObject;
            TBaseObject BaseObject;
            TUserCastle Castle;
            IList<TPlayObject> PlayObjectList;
            byte nCode = 0;
            const string sPayMentExpire = "您的帐户充值时间已到期！！！";
            const string sDisConnectMsg = "游戏被强行中断！！！";
            const string sExceptionMsg1 = "[异常] TPlayObject::Run -> Operate 1 Code={0}";
            const string sExceptionMsg2 = "[异常] TPlayObject::Run -> Operate 2 # %s Ident:%d Sender:%d wP:%d nP1:%d nP2:%d np3:%d Msg:%s Code=%d";
            const string sExceptionMsg3 = "[异常] TPlayObject::Run -> GetHighHuman Code:";
            const string sExceptionMsg4 = "[异常] TPlayObject::Run -> ClearObj";
            if (M2Share.g_boExitServer)
            {
                m_boEmergencyClose = true;
                m_boPlayOffLine = false;
                m_boNotOnlineAddExp = false;
                m_boStartAutoAddExpPoint = false;
            }
            if (!this.m_boUseBatter)
            {
                if (this.m_boCanUseBatter) // 这里是检测 无需打开连击
                {
                    this.AllowBatterHitSkill(false);
                }
            }
            if (this.m_boUseBatter)
            {
                if ((HUtil32.GetTickCount() - this.m_dwLatestBatterHitTick) < 10000)
                {
                    ClientUseBatter(null);
                }
                else
                {
                    this.m_boUseBatter = false;
                    this.SendMsg(this, Grobal2.RM_BATTERUSEFINALLY, 0, 0, 0, 0, "");
                    if ((this.m_btJob == 1) || (this.m_btJob == 2))
                    {
                        m_boCanSpell = true;// 可以魔法
                        m_boCanWalk = true;
                        m_boCanRun = true;
                        m_boCanHit = true;
                    }
                }
            }
            try
            {
                if ((HUtil32.GetTickCount() - this.m_dwVerifyTick) > 30000)  // 30 * 1000
                {
                    this.m_dwVerifyTick = HUtil32.GetTickCount();// 清组队已死亡成员
                    if (this.m_btRaceServer == Grobal2.RC_PLAYOBJECT)
                    {
                        if ((m_GroupOwner != null))
                        {
                            if (m_GroupOwner.m_boDeath || m_GroupOwner.m_boGhost)
                            {
                                m_GroupOwner = null;
                            }
                        }
                        if (m_GroupOwner == this)
                        {
                            for (int i = m_GroupMembers.Count - 1; i >= 0; i--)
                            {
                                if (m_GroupMembers.Count <= 0)
                                {
                                    break;
                                }
                                BaseObject = m_GroupMembers[i];
                                if (BaseObject != null)
                                {
                                    if (BaseObject.m_boDeath || (BaseObject.m_boGhost))
                                    {
                                        m_GroupMembers.RemoveAt(i);
                                    }
                                }
                            }
                        }
                        // 清组队已死亡成员 结束
                        if ((m_DealCreat != null) && (m_DealCreat.m_boGhost))// 检查交易双方 状态
                        {
                            m_DealCreat = null;
                        }
                    }
                    if (!this.m_boDenyRefStatus)
                    {
                        this.m_PEnvir.VerifyMapTime(this.m_nCurrX, this.m_nCurrY, this);// 刷新在地图上位置的时间
                    }
                }
                if (m_boDealing)
                {
                    if ((this.GetPoseCreate() != m_DealCreat) || (m_DealCreat == this) || (m_DealCreat == null))
                    {
                        DealCancel();
                    }
                    nCode = 1;
                }
                if (m_boExpire)// 账号过期
                {
                    this.SysMsg(sPayMentExpire, TMsgColor.c_Red, TMsgType.t_Hint);
                    this.SysMsg(sDisConnectMsg, TMsgColor.c_Red, TMsgType.t_Hint);
                    m_boEmergencyClose = true;
                    m_boPlayOffLine = false;
                    m_boNotOnlineAddExp = false;
                    m_boStartAutoAddExpPoint = false;
                    m_boExpire = false;
                }
                nCode = 2;
                if (m_boNotOnlineAddExp && m_boStartAutoAddExpPoint && (m_nNotOnlineAddExpPoint > 0))// 离线挂机人物 自动增加经验
                {
                    if ((HUtil32.GetTickCount() - m_dwAutoAddExpPointTick) >= 60000)// 1000 * 60
                    {
                        m_dwAutoAddExpPointTick = HUtil32.GetTickCount();
                        GetExp(m_nNotOnlineAddExpPoint, false, 0);
                    }
                    if ((HUtil32.GetTickCount() - m_dwAutoAddExpPointTimeTick) >= m_dwNotOnlineAddExpTime * 1000) // 挂机时间到
                    {
                        m_boPlayOffLine = false;
                        m_boNotOnlineAddExp = false;
                        m_boStartAutoAddExpPoint = false;
                    }
                }
                // ------------------------------------------------------------------------------
                // 玩家等级排名上升或下降,增加或减少英雄忠诚度
                if (!m_boNotOnlineAddExp && (HUtil32.GetTickCount() - dwGetLevelOrderTick > 600000)) // 1000 * 60 * 10
                {
                    dwGetLevelOrderTick = HUtil32.GetTickCount();
                    nCode = 200;
                    var n_mLevelOrder = GetUserLevelOrder();// 获取人物等级排名
                    if ((n_mLevelOrder > n_LevelOrder) && (n_LevelOrder != 0))  // 排名下降
                    {
                        if ((m_MyHero != null) && ((m_boHasHero || m_boHasHeroTwo) && (m_sHeroCharName != "")))
                        {
                            ((THeroObject)(m_MyHero)).m_nLoyal = HUtil32._MAX(0, ((THeroObject)(m_MyHero)).m_nLoyal - M2Share.g_Config.nLevelOrderDecLoyal);
                        }
                        nCode = 201;
                        this.SysMsg(string.Format(GameMsgDef.sHumLevelOrderDropMsg, n_mLevelOrder, (n_mLevelOrder - n_LevelOrder)), TMsgColor.c_Blue, TMsgType.t_Hint);// 人物排行下降进行提示
                        n_LevelOrder = n_mLevelOrder;
                    }
                    if ((n_mLevelOrder < n_LevelOrder) && (n_LevelOrder != 0)) // 排名上升
                    {
                        if ((m_MyHero != null) && ((m_boHasHero || m_boHasHeroTwo) && (m_sHeroCharName != "")))
                        {
                            ((THeroObject)(m_MyHero)).m_nLoyal = ((THeroObject)(m_MyHero)).m_nLoyal + M2Share.g_Config.nLevelOrderIncLoyal;
                            if (((THeroObject)(m_MyHero)).m_nLoyal > 10000)
                            {
                                ((THeroObject)(m_MyHero)).m_nLoyal = 10000;
                            }
                        }
                        n_LevelOrder = n_mLevelOrder;
                    }
                    if (n_LevelOrder == 0)
                    {
                        n_LevelOrder = n_mLevelOrder;
                    }
                }
                nCode = 202;
                if (!this.m_PEnvir.m_boFight4Zone)// 气血石 魔血石,挑战地图不能使用
                {
                    PlaySuperRock();
                }
                // ------------------------------------------------------------------------------
                nCode = 3;
                if (!m_boNotOnlineAddExp) // 如果是离线挂机的，不检测
                {
                    nCode = 42;
                    if (this.m_boFireHitSkill && ((HUtil32.GetTickCount() - this.m_dwLatestFireHitTick) > 20000))    // 20 * 1000
                    {
                        this.m_boFireHitSkill = false;
                        this.SysMsg(GameMsgDef.sSpiritsGone, TMsgColor.c_Red, TMsgType.t_Hint);
                        if (this.m_btRaceServer == Grobal2.RC_HEROOBJECT)
                        {
                            unsafe
                            {
                                if ((this.m_MagicArr[0][MagicConst.SKILL_FIRESWORD].btLevel == 4) && (((THeroObject)(this.m_MyHero)).m_nLoyal >= M2Share.g_Config.nGotoLV4))
                                {
                                    SendSocket(null, "+U4FIR"); // 关闭4级烈火
                                }
                                else
                                {
                                    SendSocket(null, "+UFIR");
                                }
                            }
                        }
                        else
                        {
                            unsafe
                            {
                                // 不是英雄无需忠诚度提示
                                if ((this.m_MagicArr[0][MagicConst.SKILL_FIRESWORD].btLevel == 4))
                                {
                                    SendSocket(null, "+U4FIR");  // 关闭4级烈火
                                }
                                else
                                {
                                    SendSocket(null, "+UFIR");
                                }
                            }
                        }
                    }
                    // ------------------------------------------------------------------------------
                    nCode = 43;
                    if (this.m_boDailySkill && ((HUtil32.GetTickCount() - this.m_dwLatestDailyTick) > 20000)) // 逐日剑法  20 * 1000
                    {
                        this.m_boDailySkill = false;
                        this.SysMsg(GameMsgDef.sDailySpiritsGone, TMsgColor.c_Red, TMsgType.t_Hint);
                        unsafe
                        {
                            SendSocket(null, "+UDAILY");
                        }
                    }
                    // ------------------------------------------------------------------------------
                    nCode = 44;
                    if (this.m_bo42kill && ((HUtil32.GetTickCount() - this.m_dwLatest42Tick) > 20000)) // 开天斩 20 * 1000
                    {
                        this.m_bo42kill = false;
                        this.SysMsg(GameMsgDef.sSkill42Off, TMsgColor.c_Red, TMsgType.t_Hint);
                        unsafe
                        {
                            switch (this.m_n42kill)// 判断轻击重击
                            {
                                case 1:
                                    SendSocket(null, "+UQTWN"); // 关闭轻开天斩
                                    break;
                                case 2:
                                    SendSocket(null, "+UTWN"); // 关闭重开天斩
                                    break;
                            }
                        }
                        this.m_n42kill = 0;
                    }
                    // ------------------------------------------------------------------------------
                    nCode = 44;
                    if (this.m_bo43kill && ((HUtil32.GetTickCount() - this.m_dwLatest43Tick) > 20000)) // 龙影剑法  20* 1000
                    {
                        this.m_bo43kill = false;
                        this.SysMsg(GameMsgDef.sSkill43Off, TMsgColor.c_Red, TMsgType.t_Hint);
                        unsafe
                        {
                            SendSocket(null, "+UCID");// 停止使用龙影剑法}
                        }
                        if (this.m_boYTPDHitSkill && ((HUtil32.GetTickCount() - this.m_dwLatestYTPDHitTick) > 20000)) // 倚天劈地 20 * 1000
                        {
                            this.m_boYTPDHitSkill = false;
                            this.SysMsg(GameMsgDef.sYTPDSpiritsGone, TMsgColor.c_Red, TMsgType.t_Hint);
                            unsafe
                            {
                                SendSocket(null, "+UYTPD");
                            }
                        }
                        if (this.m_boXPYJHitSkill && ((HUtil32.GetTickCount() - this.m_dwLatestXPYJHittick) > 20000)) // 血魄一击 20 * 1000
                        {
                            this.m_boXPYJHitSkill = false;
                            this.SysMsg(GameMsgDef.sXPYJSpiritsGone, TMsgColor.c_Red, TMsgType.t_Hint);
                            unsafe
                            {
                                SendSocket(null, "+UXPYJ");
                            }
                        }
                    }
                    //-------------------------------饮酒酒量进度增加----------------------------------------------- 
                    nCode = 45;
                    if (this.m_Abil.WineDrinkValue > 0) // 醉酒度大于0时才处理
                    {
                        if ((HUtil32.GetTickCount() - m_dwAddAlcoholTick + n_DrinkWineQuality * 1000 > M2Share.g_Config.nIncAlcoholTick * 1000) && !n_DrinkWineDrunk)
                        {
                            m_dwAddAlcoholTick = HUtil32.GetTickCount();// 增加酒量进度
                            this.SendRefMsg(Grobal2.RM_MYSHOW, 8, 0, 0, 0, "");// 酒量增加动画 
                            this.m_Abil.Alcohol += (ushort)HUtil32._MAX(5, (n_DrinkWineAlcohol * this.m_Abil.MaxAlcohol) / 1000);// 酒度数 决定增长量
                            if (this.m_Abil.Alcohol > this.m_Abil.MaxAlcohol)
                            {
                                this.m_Abil.Alcohol = Convert.ToUInt16(this.m_Abil.Alcohol - this.m_Abil.MaxAlcohol); // 酒量升级
                                this.m_Abil.MaxAlcohol = Convert.ToUInt16(this.m_Abil.MaxAlcohol + M2Share.g_Config.nIncAlcoholValue);
                                this.SysMsg(GameMsgDef.g_sUpAlcoholHintMsg, TMsgColor.c_Green, TMsgType.t_Hint);// 提示用户 '您的酒量增加了'
                                if (this.m_MagicArr[0][MagicConst.SKILL_67] != null)
                                {
                                    // 先天元力魔法升级
                                    this.m_MagicArr[0][MagicConst.SKILL_67].nTranPoint = this.m_Abil.MaxAlcohol;
                                    if (!this.CheckMagicLevelup(this.m_MagicArr[0][MagicConst.SKILL_67]))
                                    {
                                        this.SendDelayMsg(this, Grobal2.RM_MAGIC_LVEXP, 0, this.m_MagicArr[0][MagicConst.SKILL_67].MagicInfo.wMagicId, this.m_MagicArr[0][MagicConst.SKILL_67].btLevel,
                                            this.m_MagicArr[0][MagicConst.SKILL_67].nTranPoint, "", 1000);
                                    }
                                    if (this.m_Abil.WineDrinkValue >= Math.Abs(this.m_Abil.MaxAlcohol * M2Share.g_Config.nMinDrinkValue67 / 100))
                                    {
                                        // 酒量大于或等于酒量上限的5%时才有效
                                        if (this.m_MagicArr[0][MagicConst.SKILL_67].btLevel > 0)
                                        {
                                            this.m_WAbil.AC = HUtil32.MakeLong(HUtil32.LoWord(this.m_WAbil.AC), HUtil32.HiWord(this.m_WAbil.AC) + this.m_MagicArr[0][MagicConst.SKILL_67].btLevel * 2);
                                            this.m_WAbil.MAC = HUtil32.MakeLong(HUtil32.LoWord(this.m_WAbil.MAC), HUtil32.HiWord(this.m_WAbil.MAC) + this.m_MagicArr[0][MagicConst.SKILL_67].btLevel * 2);
                                            this.SendMsg(this, Grobal2.RM_ABILITY, 0, 0, 0, 0, "");// 增加
                                        }
                                    }
                                }
                            }
                            GetNGExp(M2Share.g_Config.nDrinkIncNHExp, 2);// 饮酒增加内功经验
                            RecalcAbilitys();
                            this.CompareSuitItem(false);// 套装
                            this.SendMsg(this, Grobal2.RM_PLAYMAKEWINEABILITY, 0, 0, 0, 0, "");// 酒2相关属性
                        }
                        if (HUtil32.GetTickCount() - m_dwDecWineDrinkValueTick > M2Share.g_Config.nDesDrinkTick * 1000)// 减少醉酒度
                        {
                            m_dwDecWineDrinkValueTick = HUtil32.GetTickCount();
                            this.m_Abil.WineDrinkValue = (ushort)HUtil32._MAX(0, this.m_Abil.WineDrinkValue - this.m_Abil.MaxAlcohol / 100);
                            if (this.m_Abil.WineDrinkValue == 0)
                            {
                                n_DrinkWineQuality = 0;// 饮酒时酒的品质
                                n_DrinkWineAlcohol = 0;// 饮酒时酒的度数
                                n_DrinkWineDrunk = false;// 喝酒醉了 
                                this.SysMsg(GameMsgDef.g_sJiujinOverHintMsg, TMsgColor.c_Green, TMsgType.t_Hint);// 提示用户
                            }
                            RecalcAbilitys();
                            this.CompareSuitItem(false);// 套装
                            this.SendMsg(this, Grobal2.RM_PLAYMAKEWINEABILITY, 0, 0, 0, 0, "");// 酒2相关属性
                        }
                    }
                    // ------------------------------------------------------------------------------
                    nCode = 46;
                    // 护体神盾  最长时间如果设置为0,开启一次就一直开着   使用间隔如果设置为0，那么破了以后就自动开
                    if ((this.m_MagicArr[0][MagicConst.SKILL_75] != null))// 学了护体神盾,而且使用
                    {
                        if ((!M2Share.g_Config.boAutoProtection))
                        {
                            if (M2Share.g_Config.nProtectionDefenceTime == 0)
                            {
                                if (M2Share.g_Config.dwProtectionTick == 0)
                                {
                                    if (!this.m_boProtectionDefence)
                                    {
                                        this.MagProtectionDefenceUp(this.m_MagicArr[0][MagicConst.SKILL_75].btLevel);
                                    }
                                    // 自动使用护体神盾
                                    if ((this.m_MagicArr[0][MagicConst.SKILL_75].btLevel < 3)) // 增加技能修练点
                                    {
                                        if (this.m_MagicArr[0][MagicConst.SKILL_75].MagicInfo.TrainLevel[this.m_MagicArr[0][MagicConst.SKILL_75].btLevel] <= this.m_Abil.Level)
                                        {
                                            this.TrainSkill(this.m_MagicArr[0][MagicConst.SKILL_75], HUtil32.Random(3) + 1);//增加技能的修练值
                                            if (!this.CheckMagicLevelup(this.m_MagicArr[0][MagicConst.SKILL_75]))
                                            {
                                                if (this.m_btRaceServer == Grobal2.RC_PLAYOBJECT)
                                                {
                                                    this.SendDelayMsg(this, Grobal2.RM_MAGIC_LVEXP, 0, this.m_MagicArr[0][MagicConst.SKILL_75].MagicInfo.wMagicId, this.m_MagicArr[0][MagicConst.SKILL_75].btLevel,
                                                        this.m_MagicArr[0][MagicConst.SKILL_75].nTranPoint, "", 1000);
                                                }
                                            }
                                        }
                                    }
                                }
                                if (this.m_boProtectionDefence && (this.m_wStatusTimeArr[Grobal2.STATE_ProtectionDEFENCE] < 3))
                                {
                                    this.m_wStatusTimeArr[Grobal2.STATE_ProtectionDEFENCE] = 6;
                                }
                            }
                        }
                        else
                        {
                            // 选择自动开启后,暂时不考虑使用间隔
                            if ((!this.m_boProtectionDefence) && (this.m_wStatusTimeArr[Grobal2.STATE_ProtectionDEFENCE] == 0)) // 自动使用神盾
                            {
                                this.MagProtectionDefenceUp(this.m_MagicArr[0][MagicConst.SKILL_75].btLevel);// 自动使用护体神盾
                                if ((this.m_MagicArr[0][MagicConst.SKILL_75].btLevel < 3)) // 增加技能修练点
                                {
                                    if (this.m_MagicArr[0][MagicConst.SKILL_75].MagicInfo.TrainLevel[this.m_MagicArr[0][MagicConst.SKILL_75].btLevel] <= this.m_Abil.Level)
                                    {
                                        this.TrainSkill(this.m_MagicArr[0][MagicConst.SKILL_75], HUtil32.Random(3) + 1);// 增加技能的修练值
                                        if (!this.CheckMagicLevelup(this.m_MagicArr[0][MagicConst.SKILL_75]))
                                        {
                                            if (this.m_btRaceServer == Grobal2.RC_PLAYOBJECT)
                                            {
                                                this.SendDelayMsg(this, Grobal2.RM_MAGIC_LVEXP, 0, this.m_MagicArr[0][MagicConst.SKILL_75].MagicInfo.wMagicId, this.m_MagicArr[0][MagicConst.SKILL_75].btLevel,
                                                    this.m_MagicArr[0][MagicConst.SKILL_75].nTranPoint, "", 1000);
                                            }
                                        }
                                    }
                                }
                                if (M2Share.g_Config.boShowProtectionEnv)
                                {
                                    this.SendRefMsg(Grobal2.RM_MYSHOW, Grobal2.ET_PROTECTION_STRUCK, 0, 0, 0, "");// 发送护体神盾开启动画
                                }
                            }
                        }
                    }
                    nCode = 47;
                    if (m_boRunHumanMode && (HUtil32.GetTickCount() - dwRunHumanModeTick > dwRunHumanModeTime))// 改变穿人模式
                    {
                        m_boRunHumanMode = false;
                        M2Share.g_Config.boRUNHUMAN = M2Share.ServerConfig.GetConfig<bool>("Setup", "RunHuman", M2Share.g_Config.boRUNHUMAN);
                        M2Share.g_Config.boRUNMON = M2Share.ServerConfig.GetConfig<bool>("Setup", "RunMon", M2Share.g_Config.boRUNMON);
                        SendServerConfig();// 发送配置信息到客户端
                    }
                }
                nCode = 4;
                if (m_boTimeRecall && (HUtil32.GetTickCount() > m_dwTimeRecallTick))
                {
                    m_boTimeRecall = false; // 执行 TimeRecall回到原地
                    this.SpaceMove(m_sMoveMap, m_nMoveX, m_nMoveY, 0);
                }
                for (int i = 0; i <= 20; i++)// 个人定时器
                {
                    if (AutoTimerStatus[i] > 500)
                    {
                        if ((HUtil32.GetTickCount() - AutoTimerTick[i]) > AutoTimerStatus[i])
                        {
                            if (M2Share.g_ManageNPC != null)
                            {
                                AutoTimerTick[i] = HUtil32.GetTickCount();
                                M2Share.g_ManageNPC.GotoLable(this, "@OnTimer" + i, false);
                            }
                        }
                    }
                }
                nCode = 5;
                if (m_boTimeGoto && (HUtil32.GetTickCount() > m_dwTimeGotoTick))// 执行 Delaygoto延时跳转
                {
                    m_boTimeGoto = false;
                    if (m_TimeGotoNPC != null)
                    {
                        m_TimeGotoNPC.GotoLable(this, m_sTimeGotoLable, false);
                    }
                }
                nCode = 6;
                if ((HUtil32.GetTickCount() - m_dwCheckDupObjTick) > 3000)
                {
                    m_dwCheckDupObjTick = HUtil32.GetTickCount();
                    GetStartPoint();
                    nCode = 7;
                    if (!m_boNotOnlineAddExp) // 如果是离线挂机的，不检测
                    {
                        tObjCount = this.m_PEnvir.GetXYObjCount(this.m_nCurrX, this.m_nCurrY);
                        nCode = 8;
                        if (tObjCount >= 2)
                        {
                            if (!this.bo2F0)
                            {
                                this.bo2F0 = true;
                                this.m_dwDupObjTick = HUtil32.GetTickCount();
                            }
                        }
                        else
                        {
                            this.bo2F0 = false;
                        }
                        if ((((tObjCount >= 3) && ((HUtil32.GetTickCount() - this.m_dwDupObjTick) > 3000)) || (((tObjCount == 2) && ((HUtil32.GetTickCount() - this.m_dwDupObjTick) > 10000))))
                            && ((HUtil32.GetTickCount() - this.m_dwDupObjTick) < 20000))
                        {
                            TPlayObject PushedObject = null;
                            var dwStationTick = HUtil32.GetTickCount();
                            PlayObjectList = new List<TPlayObject>();
                            try
                            {
                                nCode = 9;
                                this.m_PEnvir.GeTBaseObjects(this.m_nCurrX, this.m_nCurrY, false, PlayObjectList);
                                nCode = 10;
                                if (PlayObjectList.Count > 0)
                                {
                                    for (int i = 0; i < PlayObjectList.Count; i++)
                                    {
                                        PlayObject = PlayObjectList[i];
                                        if ((HUtil32.GetTickCount() - PlayObject.m_dwStationTick) < dwStationTick)
                                        {
                                            PushedObject = PlayObject;
                                            dwStationTick = HUtil32.GetTickCount() - PlayObject.m_dwStationTick;
                                        }
                                    }
                                }
                                nCode = 11;
                                if (PushedObject != null)
                                {
                                    PushedObject.CharPushed((byte)HUtil32.Random(8), 1);// 推开重叠人物
                                }
                                nCode = 12;
                            }
                            finally
                            {
                                Dispose(PlayObjectList);
                            }
                        }
                    }
                }
                nCode = 13;
                Castle = M2Share.g_CastleManager.InCastleWarArea(this);
                if ((Castle != null) && Castle.m_boUnderWar)// 正在攻城
                {
                    this.ChangePKStatus(true);
                }
                nCode = 14;
                if ((HUtil32.GetTickCount() - dwTick578) > 1000)
                {
                    dwTick578 = HUtil32.GetTickCount();
                    int wHour = DateTime.Now.Hour;
                    int wMin = DateTime.Now.Minute;
                    int wSec = DateTime.Now.Second;
                    int wMSec = DateTime.Now.Millisecond;
                    if (M2Share.g_Config.boDiscountForNightTime && ((wHour == M2Share.g_Config.nHalfFeeStart) || (wHour == M2Share.g_Config.nHalfFeeEnd)))
                    {
                        if ((wMin == 0) && (wSec <= 30) && ((HUtil32.GetTickCount() - m_dwLogonTick) > 60000))
                        {
                            LogonTimcCost();
                            m_dwLogonTick = HUtil32.GetTickCount();
                            m_dLogonTime = DateTime.Now;
                        }
                    }
                    if ((this.m_MyGuild != null))
                    {
                        if (this.m_MyGuild.GuildWarList.Count > 0)
                        {
                            var boInSafeArea = this.InSafeArea();
                            if (boInSafeArea != m_boInSafeArea)
                            {
                                m_boInSafeArea = boInSafeArea;
                                this.RefNameColor();
                            }
                        }
                    }
                    nCode = 15;
                    if ((Castle != null) && Castle.m_boUnderWar)
                    {
                        if ((this.m_PEnvir == Castle.m_MapPalace) && (this.m_MyGuild != null))
                        {
                            if (!Castle.IsMember(this))
                            {
                                if (Castle.IsAttackGuild(this.m_MyGuild))
                                {
                                    if (Castle.CanGetCastle(this.m_MyGuild))
                                    {
                                        Castle.GetCastle(this.m_MyGuild);
                                        M2Share.UserEngine.SendServerGroupMsg(Grobal2.SS_211, M2Share.nServerIndex, this.m_MyGuild.sGuildName);
                                        if (Castle.InPalaceGuildCount() <= 1)
                                        {
                                            Castle.StopWallconquestWar();
                                        }
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        this.ChangePKStatus(false);
                    }
                    nCode = 16;
                    if (this.m_boNameColorChanged)
                    {
                        this.m_boNameColorChanged = false;
                        RefUserState();
                        this.RefShowName();
                    }
                    nCode = 17;
                }
                if ((HUtil32.GetTickCount() - dwTick57C) > 500)
                {
                    dwTick57C = HUtil32.GetTickCount();
                }
            }
            catch
            {
                M2Share.MainOutMessage(string.Format(sExceptionMsg1, nCode));
            }
            try
            {
                nCode = 18;
                m_dwGetMsgTick = HUtil32.GetTickCount();
                while ((HUtil32.GetTickCount() - m_dwGetMsgTick < M2Share.g_Config.dwHumanGetMsgTime) && this.GetMessage(ref ProcessMsg))
                {
                    if (!Operate(ProcessMsg))
                    {
                        break;
                    }
                }
                ProcessMsg = null;
                nCode = 19;
                if (m_boEmergencyClose || m_boKickFlag || m_boSoftClose)
                {
                    nCode = 20;
                    if (m_boPlayOffLine && !m_boNotOnlineAddExp && (!M2Share.g_boExitServer) && !m_boExpire && !m_boReconnection)
                    {
                        nCode = 21;
                        GetBackSellOffItems();// 取备份元宝寄售列表物品
                        if (M2Share.g_FunctionNPC != null)
                        {
                            M2Share.g_FunctionNPC.GotoLable(this, "@PlayOffLine", false);// 人物下线触发
                        }
                        if (m_boChallengeing && this.m_PEnvir.m_boFight4Zone && (m_ChallengeCreat != null))// 是否在挑战中下线
                        {
                            m_ChallengeCreat.MapRandomMove(m_ChallengeCreat.m_sLastMapName, 0);// '您挑战获胜!'
                            m_ChallengeCreat.SysMsg(GameMsgDef.g_sChallengeWinMsg, TMsgColor.c_Blue, TMsgType.t_Hint);
                            m_ChallengeCreat.m_boChallengeing = false;
                            m_ChallengeCreat.WinGetChallengeItems();// 人物挑战中小退则输
                        }
                    }
                    if (m_boPlayOffLine && !m_boNotOnlineAddExp && (!M2Share.g_boExitServer) && !m_boExpire && m_boReconnection)
                    {
                        nCode = 22;
                        GetBackSellOffItems();// 取备份元宝寄售列表物品
                        if (M2Share.g_FunctionNPC != null)
                        {
                            M2Share.g_FunctionNPC.GotoLable(this, "@PlayReconnection", false);// 人物小退触发
                        }
                        if (m_boChallengeing && this.m_PEnvir.m_boFight4Zone && (m_ChallengeCreat != null))
                        {
                            m_ChallengeCreat.MapRandomMove(m_ChallengeCreat.m_sLastMapName, 0);// '您挑战获胜!'
                            m_ChallengeCreat.SysMsg(GameMsgDef.g_sChallengeWinMsg, TMsgColor.c_Blue, TMsgType.t_Hint);
                            m_ChallengeCreat.m_boChallengeing = false;
                            m_ChallengeCreat.WinGetChallengeItems();// 人物挑战中小退则输
                        }
                    }
                    nCode = 23;
                    if (m_boSwitchData)
                    {
                        this.m_sMapName = m_sSwitchMapName;
                        this.m_nCurrX = m_nSwitchMapX;
                        this.m_nCurrY = m_nSwitchMapY;
                    }
                    nCode = 24;
                    if (!m_boNotOnlineAddExp)// 如果不是离线挂机人物 可以下线
                    {
                        MakeGhost();
                    }
                    if (m_boKickFlag)
                    {
                        SendDefMessage(Grobal2.SM_OUTOFCONNECTION, 0, 0, 0, 0, "");
                    }
                    nCode = 25;
                    if (!m_boReconnection && m_boSoftClose)
                    {
                        nCode = 26;
                        if (m_boNotOnlineAddExp && !m_boKickAutoAddExpUser)
                        {
                            nCode = 27;
                            m_boKickAutoAddExpUser = true;
                            M2Share.FrmIDSoc.SendHumanLogOutMsg(m_sUserID, m_nSessionID);
                        }
                        else if (!m_boNotOnlineAddExp && !m_boKickAutoAddExpUser)
                        {
                            nCode = 28;
                            m_boKickAutoAddExpUser = true;
                            M2Share.FrmIDSoc.SendHumanLogOutMsg(m_sUserID, m_nSessionID);//发送人物小退消息
                        }
                    }
                }
            }
            catch
            {
                if (ProcessMsg.wIdent == 0)
                {
                    MakeGhost();
                }
                M2Share.MainOutMessage(string.Format(sExceptionMsg2, this.m_sCharName, ProcessMsg.wIdent,
                    ProcessMsg.BaseObject, ProcessMsg.wParam, ProcessMsg.nParam1, ProcessMsg.nParam2,
                    ProcessMsg.nParam3, ProcessMsg.sMsg, nCode));
            }
            try
            {
                var boTakeItem = false;// 检查身上的装备有没不符合
                for (int i = m_UseItems.GetLowerBound(0); i <= m_UseItems.GetUpperBound(0); i++)
                {
                    if (this.m_UseItems[i] != null && this.m_UseItems[i].wIndex > 0)
                    {
                        var StdItem = M2Share.UserEngine.GetStdItem(this.m_UseItems[i].wIndex);
                        if (StdItem != null)
                        {
                            if (!CheckItemsNeed(StdItem))
                            {
                                var userItem = new TUserItem();//By John 修正
                                userItem = this.m_UseItems[i];
                                if (this.AddItemToBag(userItem))
                                {
                                    SendAddItem(userItem);
                                    this.WeightChanged();
                                    boTakeItem = true;
                                }
                                else
                                {
                                    if (this.DropItemDown(userItem, 3, false, false, null, this))
                                    {
                                        boTakeItem = true;
                                    }
                                }
                                if (boTakeItem)
                                {
                                    SendDelItems(this.m_UseItems[i]);
                                    this.m_UseItems[i].wIndex = 0;
                                    RecalcAbilitys();
                                    this.CompareSuitItem(false);//套装
                                }
                            }
                        }
                        else
                        {
                            this.m_UseItems[i].wIndex = 0;
                        }
                    }
                }
            }
            catch
            {
                M2Share.MainOutMessage("[异常] TPlayObject::Run -> CheckItems");
            }
            try
            {
                if (m_boRunPlayRobotManage)
                {
                    m_PlayRobotManage.Run();// 运行个人机器人
                }
                // 无人不刷怪,有人才刷怪地图(进入地图后,直接修改刷怪索引)
                if (this.m_PEnvir.m_boNoManNoMon && (this.m_PEnvir.HumCount > 0) && (this.m_PEnvir.MonCount == 0))
                {
                    M2Share.UserEngine.GetMapMonGenIdx(this.m_PEnvir, ref M2Share.UserEngine.m_nCurrMonGen);//获取当前刷怪索引
                }
                tObjCount = m_nGameGold;
                if (m_boDecGameGold && (HUtil32.GetTickCount() - m_dwDecGameGoldTick > m_dwDecGameGoldTime))// 自动减游戏币
                {
                    m_dwDecGameGoldTick = HUtil32.GetTickCount();
                    if (m_nGameGold >= m_nDecGameGold)
                    {
                        m_nGameGold -= m_nDecGameGold;
                        nInteger = m_nDecGameGold;
                    }
                    else
                    {
                        nInteger = m_nGameGold;
                        m_nGameGold = 0;
                        m_boDecGameGold = false;
                        MoveToHome();// 减完则送回回城点
                    }
                    if (M2Share.g_boGameLogGameGold)
                    {
                        M2Share.AddGameDataLog(string.Format(GameMsgDef.g_sGameLogMsg1, M2Share.LOG_GAMEGOLD, this.m_sMapName,
                            this.m_nCurrX, this.m_nCurrY, this.m_sCharName, M2Share.g_Config.sGameGoldName, m_nGameGold, "-(" + (nInteger).ToString() + ")", "Auto"));
                    }
                }
                if (m_boIncGameGold && (HUtil32.GetTickCount() - m_dwIncGameGoldTick > m_dwIncGameGoldTime)) // 自动加游戏币
                {
                    m_dwIncGameGoldTick = HUtil32.GetTickCount();
                    if (m_nGameGold + m_nIncGameGold < int.MaxValue)
                    {
                        m_nGameGold += m_nIncGameGold;
                        nInteger = m_nIncGameGold;
                    }
                    else
                    {
                        m_nGameGold = int.MaxValue;
                        nInteger = int.MaxValue - m_nGameGold;
                        m_boIncGameGold = false;
                    }
                    if (M2Share.g_boGameLogGameGold)
                    {
                        M2Share.AddGameDataLog(string.Format(GameMsgDef.g_sGameLogMsg1, M2Share.LOG_GAMEGOLD, this.m_sMapName,
                            this.m_nCurrX, this.m_nCurrY, this.m_sCharName, M2Share.g_Config.sGameGoldName, m_nGameGold, "+(" + (nInteger).ToString() + ")", "Auto"));
                    }
                }
                if (!m_boDecGameGold && this.m_PEnvir.m_boDecGameGold)
                {
                    if (HUtil32.GetTickCount() - m_dwDecGameGoldTick > ((uint)this.m_PEnvir.m_nDECGAMEGOLDTIME * 1000))
                    {
                        m_dwDecGameGoldTick = HUtil32.GetTickCount();
                        if (m_nGameGold >= this.m_PEnvir.m_nDecGameGold)
                        {
                            m_nGameGold -= this.m_PEnvir.m_nDecGameGold;
                            nInteger = this.m_PEnvir.m_nDecGameGold;
                        }
                        else
                        {
                            nInteger = m_nGameGold;
                            m_nGameGold = 0;
                            m_boDecGameGold = false;
                            MoveToHome();
                        }
                        if (M2Share.g_boGameLogGameGold)
                        {
                            M2Share.AddGameDataLog(string.Format(GameMsgDef.g_sGameLogMsg1, M2Share.LOG_GAMEGOLD,
                                this.m_sMapName, this.m_nCurrX, this.m_nCurrY, this.m_sCharName, M2Share.g_Config.sGameGoldName, m_nGameGold,
                                "-(" + nInteger + ")", "Map"));
                        }
                    }
                }
                if (!m_boIncGameGold && this.m_PEnvir.m_boIncGameGold)
                {
                    if (HUtil32.GetTickCount() - m_dwIncGameGoldTick > ((uint)this.m_PEnvir.m_nINCGAMEGOLDTIME * 1000))
                    {
                        m_dwIncGameGoldTick = HUtil32.GetTickCount();
                        if (m_nGameGold + this.m_PEnvir.m_nIncGameGold <= int.MaxValue)
                        {
                            m_nGameGold += this.m_PEnvir.m_nIncGameGold;
                            nInteger = this.m_PEnvir.m_nIncGameGold;
                        }
                        else
                        {
                            nInteger = int.MaxValue - m_nGameGold;
                            m_nGameGold = int.MaxValue;
                        }
                        if (M2Share.g_boGameLogGameGold)
                        {
                            M2Share.AddGameDataLog(string.Format(GameMsgDef.g_sGameLogMsg1, M2Share.LOG_GAMEGOLD, this.m_sMapName, this.m_nCurrX, this.m_nCurrY,
                                this.m_sCharName, M2Share.g_Config.sGameGoldName, m_nGameGold, "+(" + nInteger + ")", "Map"));
                        }
                    }
                }
                if (tObjCount != m_nGameGold)
                {
                    this.SendUpdateMsg(this, Grobal2.RM_GOLDCHANGED, 0, 0, 0, 0, "");
                }
                if (this.m_PEnvir.m_boINCGAMEPOINT) // 自动加游戏点
                {
                    if (HUtil32.GetTickCount() - m_dwIncGamePointTick > this.m_PEnvir.m_nINCGAMEPOINTTIME * 1000)
                    {
                        m_dwIncGamePointTick = HUtil32.GetTickCount();
                        if (m_nGamePoint + this.m_PEnvir.m_nINCGAMEPOINT <= int.MaxValue)
                        {
                            m_nGamePoint += (UInt16)this.m_PEnvir.m_nINCGAMEPOINT;
                            nInteger = this.m_PEnvir.m_nINCGAMEPOINT;
                        }
                        else
                        {
                            unchecked
                            {
                                m_nGamePoint = (UInt16)int.MaxValue;
                            }
                            nInteger = int.MaxValue - m_nGamePoint;
                        }
                        if (M2Share.g_boGameLogGamePoint)
                        {
                            M2Share.AddGameDataLog(string.Format(GameMsgDef.g_sGameLogMsg1, M2Share.LOG_GAMEPOINT, this.m_sMapName,
                                this.m_nCurrX, this.m_nCurrY, this.m_sCharName, M2Share.g_Config.sGamePointName, nInteger, "+", "Map"));
                        }
                    }
                }
                if (this.m_PEnvir.m_boDECGAMEPOINT)// 自动减游戏点
                {
                    if (HUtil32.GetTickCount() - m_dwDecGamePointTick > this.m_PEnvir.m_nDECGAMEPOINTTIME * 1000)
                    {
                        m_dwDecGamePointTick = HUtil32.GetTickCount();
                        if (m_nGamePoint >= this.m_PEnvir.m_nDECGAMEPOINT)
                        {
                            m_nGamePoint -= (UInt16)this.m_PEnvir.m_nDECGAMEPOINT;
                            nInteger = this.m_PEnvir.m_nDECGAMEPOINT;
                        }
                        else
                        {
                            m_nGamePoint = 0;
                            nInteger = m_nGamePoint;
                            MoveToHome();// 移动到回城点
                        }
                        if (M2Share.g_boGameLogGamePoint)// 写入日志
                        {
                            M2Share.AddGameDataLog(string.Format(GameMsgDef.g_sGameLogMsg1, M2Share.LOG_GAMEPOINT, this.m_sMapName,
                            this.m_nCurrX, this.m_nCurrY, this.m_sCharName, M2Share.g_Config.sGamePointName, nInteger, "-", "Map"));
                        }
                    }
                }
                if (this.m_PEnvir.m_boMISSION) // 不允许使用任何物品和技能
                {
                    m_boCanUseItem = false;// 不允许使用物品
                    m_boCanSpell = false;// 不允许使用技能
                    this.KillSlave();// 清除下属
                    if (m_MyHero != null)
                    {
                        ((THeroObject)(m_MyHero)).m_boCanUseItem = false;
                        ((THeroObject)(m_MyHero)).m_boCanSpell = false;
                        ((THeroObject)(m_MyHero)).m_boNoAttackMode = true;// 不可以攻击模式
                    }
                }
                else
                {
                    if (M2Share.g_Config.boLockHumanLogin && m_boLockLogon && m_boPasswordLocked)// 如果开启密码保护,没有解密时
                    {
                        m_boCanSpell = !M2Share.g_Config.boLockSpellAction;// 允许使用技能
                    }
                    else if (m_boUnLockPwd)
                    {
                        if (M2Share.g_Config.boLockSpellAction)
                        {
                            m_boCanSpell = true;
                        }
                    }
                    else
                    {
                        m_boCanSpell = true;
                    }
                    m_boCanUseItem = true;// 允许使用物品
                    if (m_MyHero != null)
                    {
                        ((THeroObject)(m_MyHero)).m_boCanUseItem = true;
                        ((THeroObject)(m_MyHero)).m_boCanSpell = true;
                        ((THeroObject)(m_MyHero)).m_boNoAttackMode = false;// 可以攻击模式
                    }
                }
                if (this.m_PEnvir.m_boNOCALLHERO)  // 禁止召唤英雄
                {
                    m_boCallHero = false;
                    if (m_MyHero != null)
                    {
                        if (!m_MyHero.m_boDeath)
                        {
                            ClientHeroLogOut(0);// 英雄退出 
                        }
                    }
                }
                else
                {
                    if (M2Share.g_Config.boLockHumanLogin && m_boLockLogon && m_boPasswordLocked) // 如果开启密码保护,没有解密时
                    {
                        m_boCallHero = !M2Share.g_Config.boLockCallHeroAction;// 允许召唤英雄
                    }
                    else if (m_boUnLockPwd)// 解锁
                    {
                        if (M2Share.g_Config.boLockCallHeroAction)
                        {
                            m_boCallHero = true;
                        }
                    }
                    else
                    {
                        m_boCallHero = true;
                    }
                }
                if (this.m_PEnvir.m_boDECHP && (HUtil32.GetTickCount() - m_dwDecHPTick > this.m_PEnvir.m_nDECHPTIME * 1000))
                {
                    m_dwDecHPTick = HUtil32.GetTickCount();
                    if (this.m_WAbil.HP > this.m_PEnvir.m_nDECHPPOINT)
                    {
                        this.m_WAbil.HP -= this.m_PEnvir.m_nDECHPPOINT;
                    }
                    else
                    {
                        this.m_WAbil.HP = 0;
                    }
                    this.HealthSpellChanged();
                }
                if (this.m_PEnvir.m_boINCHP && (HUtil32.GetTickCount() - m_dwIncHPTick > this.m_PEnvir.m_nINCHPTIME * 1000))
                {
                    m_dwIncHPTick = HUtil32.GetTickCount();
                    if (this.m_WAbil.HP + this.m_PEnvir.m_nDECHPPOINT < this.m_WAbil.MaxHP)
                    {
                        this.m_WAbil.HP += this.m_PEnvir.m_nDECHPPOINT;
                    }
                    else
                    {
                        this.m_WAbil.HP = this.m_WAbil.MaxHP;
                    }
                    this.HealthSpellChanged();
                }
                if (M2Share.g_Config.boHungerSystem)  // 降饥饿点
                {
                    if ((HUtil32.GetTickCount() - this.m_dwDecHungerPointTick) > 1000)
                    {
                        this.m_dwDecHungerPointTick = HUtil32.GetTickCount();
                        if (m_nHungerStatus > 0)
                        {
                            tObjCount = GetMyStatus();
                            m_nHungerStatus -= 1;
                            if (tObjCount != GetMyStatus())
                            {
                                RefMyStatus();
                            }
                        }
                        else
                        {
                            if (M2Share.g_Config.boHungerDecHP) // 能量不够 减少涨HP，MP
                            {
                                this.m_nHealthTick -= 60;
                                this.m_nSpellTick -= 10;
                                this.m_nSpellTick = HUtil32._MAX(0, this.m_nSpellTick);
                                this.m_nPerHealth -= 1;
                                this.m_nPerSpell -= 1;
                                if (this.m_WAbil.HP > this.m_WAbil.HP / 100)
                                {
                                    this.m_WAbil.HP -= HUtil32._MAX(1, this.m_WAbil.HP / 100);
                                }
                                else
                                {
                                    if (this.m_WAbil.HP <= 2)
                                    {
                                        this.m_WAbil.HP = 0;
                                    }
                                }
                                this.HealthSpellChanged();
                            }
                        }
                    }
                }
            }
            catch
            {
                M2Share.MainOutMessage("[异常] TPlayObject::Run -> m_PEnvir");
            }
            try
            {
                if (HUtil32.GetTickCount() - m_dwRateTick > 1000)
                {
                    m_dwRateTick = HUtil32.GetTickCount();
                    if ((m_dwUserTick[0] > 0)) // 倒计时触发QF段
                    {
                        m_dwUserTick[0] -= 1;
                        m_dwUserTick[3]++;
                        if ((m_dwUserTick[3] >= 180) && (m_dwUserTick[0] > 0)) // 每隔4分钟，更新一次客户端的时间，以保证两边程序时间的统一
                        {
                            SendDefMessage(Grobal2.SM_UPDATETIME, (int)m_dwUserTick[0], 0, 0, 0, "");// 发送M2当前的倒计时值
                            m_dwUserTick[3] = 0;
                        }
                        if (m_dwUserTick[0] == 0)
                        {
                            if ((M2Share.g_FunctionNPC != null) && (m_sMapQFStr != ""))   // SENDTIMEMSG命令设置的触发段
                            {
                                M2Share.g_FunctionNPC.GotoLable(this, m_sMapQFStr, false);
                                m_dwUserTick[3] = 0;
                            }
                        }
                    }
                    if ((m_dwUserTick[2] > 0))  // 倒计时，发送触发段参数给客户端，并显示'!'号图标
                    {
                        m_dwUserTick[2] -= 1;
                        if (m_dwUserTick[2] == 0)
                        {
                            if ((m_sMapQFStr1 != ""))// SENDMSGWINDOWS命令设置的触发段
                            {
                                // 发消息给客户端，显示'!'号图标，点击图标则进入QF指定的触发段
                                SendDefMessage(Grobal2.SM_SHOWSIGHICON, 0, 0, 0, 0, m_sMapQFStr1);
                            }
                        }
                    }
                    if (m_dwKillMonExpRateTime > 0)
                    {
                        m_dwKillMonExpRateTime -= 1;
                        if (m_dwKillMonExpRateTime == 0)
                        {
                            m_nKillMonExpRate = 100;
                            m_nOldKillMonExpRate = m_nKillMonExpRate;
                            RecalcAbilitys();
                            this.CompareSuitItem(false);// 套装
                            this.SysMsg("经验倍数恢复正常...", TMsgColor.c_Red, TMsgType.t_Hint);
                            if (m_MyHero != null)
                            {
                                ((THeroObject)(m_MyHero)).m_nKillMonExpRate = 100;// 英雄存在,也同时设置为原来的经验倍数 
                                ((THeroObject)(m_MyHero)).m_nOldKillMonExpRate = ((THeroObject)(m_MyHero)).m_nKillMonExpRate;
                                ((THeroObject)(m_MyHero)).RecalcAbilitys();
                                m_MyHero.CompareSuitItem(false);// 套装
                            }
                        }
                    }
                    if (m_boMakeWine && (m_MakeWineTime > 0)) // 改变酿酒时间
                    {
                        m_MakeWineTime -= 1;
                    }
                    PlayGatherFountain();// 收集泉水
                    if (m_boChallengeing && this.m_PEnvir.m_boFight4Zone && (m_ChallengeTime > 0))  // 挑战计时  正在挑战中,在挑战地图,挑战时间不为零,挑战对像存在
                    {
                        m_ChallengeTime -= 1;
                        if (m_ChallengeCreat != null)
                        {
                            if (m_ChallengeTime <= 0)// 挑战时间到,没有分出胜负,则传送出挑战地图
                            {
                                if ((!this.m_boDeath) && (!m_ChallengeCreat.m_boDeath)) // 双方都没有死亡,则传送到回城地图
                                {
                                    m_ChallengeCreat.m_boChallengeing = false;
                                    m_ChallengeCreat.GetBackChallengeItems();
                                    m_ChallengeCreat.m_ChallengeCreat = null;
                                    m_ChallengeCreat.m_ChallengeLastTick = HUtil32.GetTickCount();
                                    m_ChallengeCreat.MapRandomMove(m_ChallengeCreat.m_sLastMapName, 0);// '时间到,未分出胜负'
                                    m_ChallengeCreat.SysMsg(GameMsgDef.g_sChallengeTimeOverMsg, TMsgColor.c_Blue, TMsgType.t_Hint);
                                    m_ChallengeCreat.m_WAbil.HP = m_ChallengeCreat.m_WAbil.MaxHP;
                                    m_ChallengeCreat.m_WAbil.MP = m_ChallengeCreat.m_WAbil.MaxMP;
                                    m_ChallengeCreat.HealthSpellChanged();
                                    m_boChallengeing = false;
                                    GetBackChallengeItems();
                                    m_ChallengeCreat = null;
                                    m_ChallengeLastTick = HUtil32.GetTickCount();
                                    this.MapRandomMove(m_sLastMapName, 0);// '时间到,未分出胜负'
                                    this.SysMsg(GameMsgDef.g_sChallengeTimeOverMsg, TMsgColor.c_Blue, TMsgType.t_Hint);
                                    this.m_WAbil.HP = this.m_WAbil.MaxHP;
                                    this.m_WAbil.MP = this.m_WAbil.MaxMP;
                                    this.HealthSpellChanged();
                                }
                            }
                            if (m_ChallengeCreat != null)
                            {
                                if (this.m_PEnvir != m_ChallengeCreat.m_PEnvir) // 双方不在同个地图时
                                {
                                    if (!this.m_PEnvir.m_boFight4Zone)
                                    {
                                        m_ChallengeCreat.MapRandomMove(m_ChallengeCreat.m_sLastMapName, 0);// '您挑战输了'
                                        this.SysMsg(GameMsgDef.g_sChallengeLoseMsg, TMsgColor.c_Blue, TMsgType.t_Hint);// '您挑战获胜!'
                                        m_ChallengeCreat.SysMsg(GameMsgDef.g_sChallengeWinMsg, TMsgColor.c_Blue, TMsgType.t_Hint);
                                        m_ChallengeCreat.WinGetChallengeItems();
                                    }
                                    else if (!m_ChallengeCreat.m_PEnvir.m_boFight4Zone)
                                    {
                                        this.MapRandomMove(m_sLastMapName, 0);// '您挑战获胜!'
                                        this.SysMsg(GameMsgDef.g_sChallengeWinMsg, TMsgColor.c_Blue, TMsgType.t_Hint);// '您挑战输了!'
                                        m_ChallengeCreat.SysMsg(GameMsgDef.g_sChallengeLoseMsg, TMsgColor.c_Blue, TMsgType.t_Hint);
                                        WinGetChallengeItems();
                                    }
                                }
                            }
                        }
                    }
                    // 药力值不为0,判断间隔时间内是否饮药酒,时间到没饮,则减少药力值
                    if ((this.m_Abil.MedicineValue > 0) && (dw_UseMedicineTime > 0))
                    {
                        dw_UseMedicineTime -= 1;
                        if (dw_UseMedicineTime <= 0) // 使用时间到
                        {
                            this.m_Abil.MedicineValue = (ushort)HUtil32._MAX(0, this.m_Abil.MedicineValue - M2Share.g_Config.nDesMedicineValue);
                            if (this.m_Abil.MedicineValue > 0)
                            {
                                dw_UseMedicineTime = M2Share.g_Config.nDesMedicineTick;// 始化使用药酒时间(12小时)
                            }
                            RecalcAbilitys();
                            this.CompareSuitItem(false);// 套装
                            this.SendMsg(this, Grobal2.RM_PLAYMAKEWINEABILITY, 0, 0, 0, 0, "");// 酒2相关属性
                        }
                    }
                    if (m_MyHero != null)
                    {
                        if ((m_MyHero.m_Abil.MedicineValue > 0) && (((THeroObject)(m_MyHero)).dw_UseMedicineTime > 0))
                        {
                            ((THeroObject)(m_MyHero)).dw_UseMedicineTime -= 1;
                            if (((THeroObject)(m_MyHero)).dw_UseMedicineTime <= 0)// 使用时间到
                            {
                                m_MyHero.m_Abil.MedicineValue = (ushort)HUtil32._MAX(0, m_MyHero.m_Abil.MedicineValue - M2Share.g_Config.nDesMedicineValue);
                                if (m_MyHero.m_Abil.MedicineValue > 0)
                                {
                                    ((THeroObject)(m_MyHero)).dw_UseMedicineTime = (ushort)M2Share.g_Config.nDesMedicineTick;// 始化使用药酒时间(12小时)
                                }
                                ((THeroObject)(m_MyHero)).RecalcAbilitys();
                                m_MyHero.CompareSuitItem(false);// 套装
                                ((THeroObject)(m_MyHero)).SendMsg(m_MyHero, Grobal2.RM_HEROMAKEWINEABILITY, 0, 0, 0, 0, "");// 酒2相关属性
                            }
                        }
                    }
                    if (m_dwPowerRateTime > 0)
                    {
                        m_dwPowerRateTime -= 1;
                        if (m_dwPowerRateTime == 0)
                        {
                            m_nPowerRate = 100;
                            this.SysMsg("攻击力倍数恢复正常...", TMsgColor.c_Red, TMsgType.t_Hint);
                        }
                    }
                    // 如果有聚灵珠
                    if ((n_UsesItemTick > 0) && !m_boNotOnlineAddExp && IsItem_51(0))// 非挂机状态下
                    {
                        n_UsesItemTick -= 1;
                        n_UsesItemTime++;// 聚灵珠发送剩余时间消息的时间
                        if (n_UsesItemTime >= 600)// 60 * 10
                        {
                            SendItemUseTime(n_UsesItemTick);// 10分钟更新一次剩余时间
                            n_UsesItemTime = 0;  // 发送聚灵珠使用剩余时间
                        }
                        if (n_UsesItemTick <= 0)
                        {
                            n_UsesItemTick = 0;
                            IsItem_51(2);
                            SendItemUseTime(n_UsesItemTick);// 发送聚灵珠使用剩余时间
                            this.SysMsg("【聚灵珠】聚集时间已到,不能再聚集经验，请双击使用!", TMsgColor.c_Red, TMsgType.t_Hint);
                        }
                    }
                    if (m_boTrainingNG && (m_Skill69NH < m_Skill69MaxNH))// 学过内功,间隔时间增加内力值
                    {
                        //增加内力恢复速度 
                        if (HUtil32.GetTickCount() - m_dwIncAddNHTick + HUtil32.Round((double)M2Share.g_Config.dwIncNHTime / 100 * m_dwIncAddNHTick) > M2Share.g_Config.dwIncNHTime)
                        {
                            m_dwIncNHTick = HUtil32.GetTickCount();// 内力恢复点
                            m_Skill69NH = (ushort)HUtil32._MIN(m_Skill69MaxNH, Convert.ToInt32(m_Skill69NH + HUtil32._MAX(1, (int)HUtil32.Round((double)m_Skill69MaxNH * 0.014))
                                + m_dwIncAddNHPoint));
                            this.SendRefMsg(Grobal2.RM_MAGIC69SKILLNH, 0, m_Skill69NH, m_Skill69MaxNH, 0, "");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                M2Share.MainOutMessage("[异常] TPlayObject::Run -> GetTick");
            }
            try
            {
                // 取得在线最高等级、PK、攻击力、魔法、道术 的人物
                nCode = 29;
                if ((M2Share.g_HighLevelHuman == this) && (this.m_boDeath || this.m_boGhost))
                {
                    M2Share.g_HighLevelHuman = null;
                }
                if ((M2Share.g_HighPKPointHuman == this) && (this.m_boDeath || this.m_boGhost))
                {
                    M2Share.g_HighPKPointHuman = null;
                }
                if ((M2Share.g_HighDCHuman == this) && (this.m_boDeath || this.m_boGhost))
                {
                    M2Share.g_HighDCHuman = null;
                }
                if ((M2Share.g_HighMCHuman == this) && (this.m_boDeath || this.m_boGhost))
                {
                    M2Share.g_HighMCHuman = null;
                }
                if ((M2Share.g_HighSCHuman == this) && (this.m_boDeath || this.m_boGhost))
                {
                    M2Share.g_HighSCHuman = null;
                }
                if ((M2Share.g_HighOnlineHuman == this) && (this.m_boDeath || this.m_boGhost))
                {
                    M2Share.g_HighOnlineHuman = null;
                }
                if (this.m_btPermission < 6)// 人物权限小于6
                {
                    nCode = 35;
                    if (M2Share.g_HighLevelHuman != null)
                    {
                        if (M2Share.g_HighLevelHuman.m_boGhost)
                        {
                            M2Share.g_HighLevelHuman = this;
                        }
                        else
                        {
                            if (this.m_Abil.Level > M2Share.g_HighLevelHuman.m_Abil.Level)
                            {
                                M2Share.g_HighLevelHuman = this;
                            }
                        }
                    }
                    else
                    {
                        M2Share.g_HighLevelHuman = this;
                    }
                    nCode = 36;//最高PK值
                    if ((M2Share.g_HighPKPointHuman != null))
                    {
                        if (M2Share.g_HighPKPointHuman.m_boGhost)
                        {
                            if (this.m_nPkPoint > 0)
                            {
                                M2Share.g_HighPKPointHuman = this;
                            }
                        }
                        else
                        {
                            if (this.m_nPkPoint > M2Share.g_HighPKPointHuman.m_nPkPoint)
                            {
                                M2Share.g_HighPKPointHuman = this;
                            }
                        }
                    }
                    else
                    {
                        if (this.m_nPkPoint > 0)
                        {
                            M2Share.g_HighPKPointHuman = this;
                        }
                    }
                    nCode = 37;// 最高攻击力
                    if ((M2Share.g_HighDCHuman != null))
                    {
                        if (M2Share.g_HighDCHuman.m_boGhost)
                        {
                            M2Share.g_HighDCHuman = this;
                        }
                        else
                        {
                            if (HUtil32.HiWord(this.m_WAbil.DC) > HUtil32.HiWord(M2Share.g_HighDCHuman.m_WAbil.DC))
                            {
                                M2Share.g_HighDCHuman = this;
                            }
                        }
                    }
                    else
                    {
                        M2Share.g_HighDCHuman = this;
                    }
                    nCode = 38;// 最高魔法
                    if ((M2Share.g_HighMCHuman != null))
                    {
                        if (M2Share.g_HighMCHuman.m_boGhost)
                        {
                            M2Share.g_HighMCHuman = this;
                        }
                        else
                        {
                            if (HUtil32.HiWord(this.m_WAbil.MC) > HUtil32.HiWord(M2Share.g_HighMCHuman.m_WAbil.MC))
                            {
                                M2Share.g_HighMCHuman = this;
                            }
                        }
                    }
                    else
                    {
                        M2Share.g_HighMCHuman = this;
                    }
                    nCode = 39;// 最高道术
                    if ((M2Share.g_HighSCHuman != null))
                    {
                        if (M2Share.g_HighSCHuman.m_boGhost)
                        {
                            M2Share.g_HighSCHuman = this;
                        }
                        else
                        {
                            if (HUtil32.HiWord(this.m_WAbil.SC) > HUtil32.HiWord(M2Share.g_HighSCHuman.m_WAbil.SC))
                            {
                                M2Share.g_HighSCHuman = this;
                            }
                        }
                    }
                    else
                    {
                        M2Share.g_HighSCHuman = this;
                    }
                    nCode = 40;// 最长在线时间
                    if ((M2Share.g_HighOnlineHuman != null))
                    {
                        if (M2Share.g_HighOnlineHuman.m_boGhost)
                        {
                            M2Share.g_HighOnlineHuman = this;
                        }
                        else
                        {
                            if (m_dwLogonTick < M2Share.g_HighOnlineHuman.m_dwLogonTick)
                            {
                                M2Share.g_HighOnlineHuman = this;
                            }
                        }
                    }
                    else
                    {
                        M2Share.g_HighOnlineHuman = this;
                    }
                }
            }
            catch
            {
                M2Share.MainOutMessage(sExceptionMsg3 + nCode);
            }
            try
            {
                if (!m_boNotOnlineAddExp) // 如果是离线挂机的，不检测
                {
                    if (M2Share.g_Config.boReNewChangeColor && (m_btReLevel > 0) && (HUtil32.GetTickCount() - m_dwReColorTick > M2Share.g_Config.dwReNewNameColorTime))
                    {
                        m_dwReColorTick = HUtil32.GetTickCount();
                        m_btReColorIdx++;
                        if (m_btReColorIdx > M2Share.g_Config.ReNewNameColor.GetUpperBound(0))
                        {
                            m_btReColorIdx = 0;
                        }
                        this.m_btNameColor = M2Share.g_Config.ReNewNameColor[m_btReColorIdx]; // 名称自动变色
                        this.RefNameColor();
                    }
                    if ((m_GetWhisperHuman != null))   // 检测侦听私聊对像
                    {
                        if (m_GetWhisperHuman.m_boDeath || (m_GetWhisperHuman.m_boGhost))
                        {
                            m_GetWhisperHuman = null;
                        }
                    }
                    ProcessSpiritSuite();
                }
            }
            catch
            {
                M2Share.MainOutMessage("[Exception] TPlayObject::Run Code:" + nCode);
            }
            try
            {
                if (HUtil32.GetTickCount() - m_dwClearObjTick > 60000)   // 1000 * 60
                {
                    m_dwClearObjTick = HUtil32.GetTickCount();
                    if ((m_DearHuman != null) && (m_DearHuman.m_boDeath || m_DearHuman.m_boGhost))
                    {
                        m_DearHuman = null;
                    }
                    if (m_boMaster)
                    {
                        for (int i = m_MasterList.Count - 1; i >= 0; i--)
                        {
                            if (m_MasterList.Count <= 0)
                            {
                                break;
                            }
                            PlayObject = m_MasterList[i];
                            if ((PlayObject != null) && (PlayObject.m_boDeath || PlayObject.m_boGhost))
                            {
                                m_MasterList.RemoveAt(i);
                            }
                        }
                    }
                    else
                    {
                        if ((m_MasterHuman != null) && (m_MasterHuman.m_boDeath || m_MasterHuman.m_boGhost))
                        {
                            m_MasterHuman = null;
                        }
                    }
                }
            }
            catch
            {
                M2Share.MainOutMessage(sExceptionMsg4);
            }
            try
            {
                if (!m_boNotOnlineAddExp) // 如果是离线挂机的，不检测
                {
                    if ((m_nAutoGetExpPoint > 0) && ((m_AutoGetExpEnvir == null) || (m_AutoGetExpEnvir == this.m_PEnvir))
                        && (HUtil32.GetTickCount() - m_dwAutoGetExpTick > m_nAutoGetExpTime))
                    {
                        m_dwAutoGetExpTick = HUtil32.GetTickCount();
                        if (!m_boAutoGetExpInSafeZone || (m_boAutoGetExpInSafeZone && this.InSafeZone()))
                        {
                            GetExp(m_nAutoGetExpPoint, false, 0);
                        }
                    }
                }
            }
            catch
            {
                M2Share.MainOutMessage("[异常] TPlayObject::Run -> AutoGetExp");
            }
            base.Run();
        }

        /// <summary>
        /// 人物显示名字
        /// </summary>
        /// <returns></returns>
        public override string GetShowName()
        {
            string result = string.Empty;
            string sShowName = string.Empty;
            string sCharName = string.Empty;
            string sGuildName = string.Empty;
            string sDearName = string.Empty;
            string sMasterName = string.Empty;
            TUserCastle Castle;
            byte nCode = 0;
            try
            {
                nCode = 1;
                if (this.m_MyGuild != null)
                {
                    Castle = M2Share.g_CastleManager.IsCastleMember(this);
                    nCode = 2;
                    if (Castle != null)
                    {
                        sGuildName = GameMsgDef.g_sCastleGuildName.Replace("%castlename", Castle.m_sName); // 城堡名字
                        sGuildName = sGuildName.Replace("%guildname", this.m_MyGuild.sGuildName);// 行会名字
                        sGuildName = sGuildName.Replace("%rankname", this.m_sGuildRankName);// 行会封号
                    }
                    else
                    {
                        Castle = M2Share.g_CastleManager.InCastleWarArea(this);
                        if (M2Share.g_Config.boShowGuildName || (((Castle != null) && Castle.m_boUnderWar) || this.m_boInFreePKArea))
                        {
                            sGuildName = GameMsgDef.g_sNoCastleGuildName.Replace("%guildname", this.m_MyGuild.sGuildName);
                            sGuildName = sGuildName.Replace("%rankname", this.m_sGuildRankName);
                        }
                    }
                }
                nCode = 3;
                if (!M2Share.g_Config.boShowRankLevelName)
                {
                    nCode = 31;
                    if (m_btReLevel > 0)
                    {
                        switch (this.m_btJob)
                        {
                            case 0:
                                sCharName = GameMsgDef.g_sWarrReNewName.Replace("%chrname", this.m_sCharName);
                                break;
                            case 1:
                                sCharName = GameMsgDef.g_sWizardReNewName.Replace("%chrname", this.m_sCharName);
                                break;
                            case 2:
                                sCharName = GameMsgDef.g_sTaosReNewName.Replace("%chrname", this.m_sCharName);
                                break;
                        }
                    }
                    else
                    {
                        sCharName = this.m_sCharName;
                    }
                }
                else
                {
                    nCode = 32;
                    sCharName = string.Format(m_sRankLevelName, this.m_sCharName);
                }
                nCode = 4;
                if (m_sMasterName != "")
                {
                    if (m_boMaster)
                    {
                        sMasterName = string.Format(GameMsgDef.g_sMasterName, m_sMasterName);// '的师傅'
                    }
                    else
                    {
                        sMasterName = string.Format(GameMsgDef.g_sNoMasterName, m_sMasterName, this.MoneyToCharacter(m_nMasterNo));// '的徒弟'
                    }
                }
                nCode = 5;
                if (m_sDearName != "")
                {
                    if (this.m_btGender == 0)
                    {
                        sDearName = string.Format(GameMsgDef.g_sManDearName, m_sDearName);    // + '的丈夫';

                    }
                    else
                    {
                        sDearName = string.Format(GameMsgDef.g_sWoManDearName, m_sDearName);  // + '的妻子';
                    }
                }
                nCode = 6;
                sShowName = GameMsgDef.g_sHumanShowName.ToLower().Replace("%chrname", sCharName);// 人物名
                sShowName = sShowName.Replace("%guildname", sGuildName);// 行会名
                sShowName = sShowName.Replace("%dearname", sDearName);// 夫妻名
                sShowName = sShowName.Replace("%mastername", sMasterName);// 师徒名
                result = sShowName;
                nCode = 7;
                if (M2Share.g_Config.boUnKnowHum && this.IsUsesZhuLi())
                {
                    result = "神秘人";// 带上斗笠即显示神秘人
                }
            }
            catch
            {
                M2Share.MainOutMessage("[异常] TPlayObject::GetShowName Code:" + nCode);
            }
            return result;
        }

        /// <summary>
        /// 处理角色发言数据
        /// </summary>
        /// <param name="sData"></param>
        public unsafe override void ProcessSayMsg(string sData)
        {
            bool boDisableSayMsg;
            string SC;
            string sCryCryMsg;
            string sParam1 = string.Empty;
            const string s01 = "{0} {1}";
            const string s02 = "{0} {1}({2}/{3})";
            const string sExceptionMsg = "[异常] TPlayObject.ProcessSayMsg Msg = {0}";
            if (this.m_btRaceServer != Grobal2.RC_PLAYOBJECT)
            {
                return;
            }
            try
            {
                if (sData == "")
                {
                    return;
                }
                if ((sData.Length > 1) && (sData[1] == '|'))
                {
                    SC = sData.Substring(2 - 1, sData.Length - 1);
                    if ((SC[1] == 'C') && (SC[3] == 'U') && (SC[5] == 'T'))
                    {
                        this.SysMsg(string.Format(s01, M2Share.UserEngine.m_nLimitUserCount, M2Share.UserEngine.m_nLimitNumber), TMsgColor.c_Red, TMsgType.t_Hint);// 注册人数
                        return;
                    }
                    if ((SC[1] == 'O') && (SC[6] == 'E') && (SC[11] == 'T'))
                    {
                        this.SysMsg(string.Format(s02, M2Share.g_Config.sServerName, M2Share.UserEngine.PlayObjectCount,
                            M2Share.UserEngine.PlayObjectCount - M2Share.UserEngine.AutoAddExpPlayCount, M2Share.UserEngine.AutoAddExpPlayCount),
                            TMsgColor.c_Red, TMsgType.t_Hint);// 服务器名,人数
                        return;
                    }
                    if ((SC[1] == 'S') && (SC[5] == 'T') && (SC[9] == 'E'))
                    {
                        this.SysMsg(M2Share.GetStartTime(M2Share.dwStartTime), TMsgColor.c_Red, TMsgType.t_Hint);// 运行时间
                        return;
                    }
                }
                if (sData.Length > M2Share.g_Config.nSayMsgMaxLen)
                {
                    sData = sData.Substring(1 - 1, M2Share.g_Config.nSayMsgMaxLen);
                }
                if (((HUtil32.GetTickCount() - m_dwSayMsgTick) < M2Share.g_Config.dwSayMsgTime))// 3 * 1000
                {
                    m_nSayMsgCount++;
                    if (m_nSayMsgCount >= M2Share.g_Config.nSayMsgCount)
                    {
                        m_boDisableSayMsg = true;
                        m_dwDisableSayMsgTick = HUtil32.GetTickCount() + M2Share.g_Config.dwDisableSayMsgTime;// 60 * 1000
                        // '[由于你重复发相同的内容，%d分钟内你将被禁止发言...]'
                        this.SysMsg(string.Format(GameMsgDef.g_sDisableSayMsg, M2Share.g_Config.dwDisableSayMsgTime / (60 * 1000)), TMsgColor.c_Red, TMsgType.t_Hint);
                    }
                }
                else
                {
                    m_dwSayMsgTick = HUtil32.GetTickCount();
                    m_nSayMsgCount = 0;
                }
                if (HUtil32.GetTickCount() >= m_dwDisableSayMsgTick)
                {
                    m_boDisableSayMsg = false;
                }
                boDisableSayMsg = m_boDisableSayMsg;
                lock (M2Share.g_DenySayMsgList)
                    try
                    {
                        //if (M2Share.g_DenySayMsgList.GetIndex(this.m_sCharName) >= 0)
                        //{
                        //    boDisableSayMsg = true;
                        //}
                    }
                    finally
                    {
                        //M2Share.g_DenySayMsgList.UnLock();
                    }
                if (!boDisableSayMsg)
                {
                    if (sData[0] == '/')
                    {
                        SC = sData.Substring(2 - 1, sData.Length - 1);
                        if ((SC.Trim()).ToLower().CompareTo((M2Share.g_GameCommand.WHO.sCmd.Trim()).ToLower()) == 0)
                        {
                            if ((this.m_btPermission < M2Share.g_GameCommand.WHO.nPermissionMin))
                            {
                                this.SysMsg(GameMsgDef.g_sGameCommandPermissionTooLow, TMsgColor.c_Red, TMsgType.t_Hint);
                                return;
                            }
                            //this.HearMsg(string.Format(GameMsgDef.g_sOnlineCountMsg, new int[] { M2Share.UserEngine.PlayObjectCount, M2Share.UserEngine.OnlinePlayObject, M2Share.UserEngine.AutoAddExpPlayCount }));
                            return;
                        }
                        if ((SC.Trim()).ToLower().CompareTo((M2Share.g_GameCommand.TOTAL.sCmd.Trim()).ToLower()) == 0)
                        {
                            if ((this.m_btPermission < M2Share.g_GameCommand.TOTAL.nPermissionMin))
                            {
                                this.SysMsg(GameMsgDef.g_sGameCommandPermissionTooLow, TMsgColor.c_Red, TMsgType.t_Hint);
                                return;
                            }
                            //this.HearMsg(string.Format(GameMsgDef.g_sTotalOnlineCountMsg, new int[] { GameMsgDef.g_nTotalHumCount }));
                            return;
                        }
                        SC = HUtil32.GetValidStr3(SC, ref sParam1, new string[] { " " });
                        if (!m_boFilterSendMsg)
                        {
                            Whisper(sParam1, SC);
                        }
                        return;
                    }
                    if (sData[0] == '!')
                    {
                        if (sData.Length >= 2)
                        {
                            if (sData[1] == '!')
                            {
                                SC = sData.Substring(3 - 1, sData.Length - 2);
                                SendGroupText(this.m_sCharName + ": " + SC);
                                return;
                            }
                            if (sData[1] == '~') // 行会聊天
                            {
                                if (this.m_MyGuild != null)
                                {
                                    SC = sData.Substring(3 - 1, sData.Length - 2);
                                    this.m_MyGuild.SendGuildMsg(this.m_sCharName + ": " + SC);
                                    M2Share.UserEngine.SendServerGroupMsg(Grobal2.SS_208, M2Share.nServerIndex, this.m_MyGuild.sGuildName + '/' + this.m_sCharName + '/' + SC);
                                }
                                return;
                            }
                        }
                        if (!this.m_PEnvir.m_boQUIZ)
                        {
                            if ((HUtil32.GetTickCount() - m_dwShoutMsgTick) > 10000) // 10 * 1000
                            {
                                if (this.m_Abil.Level <= M2Share.g_Config.nCanShoutMsgLevel)
                                {
                                    this.SysMsg(string.Format(GameMsgDef.g_sYouNeedLevelMsg, M2Share.g_Config.nCanShoutMsgLevel + 1), TMsgColor.c_Red, TMsgType.t_Hint);
                                    return;
                                }
                                m_dwShoutMsgTick = HUtil32.GetTickCount();
                                SC = sData.Substring(2 - 1, sData.Length - 1);
                                sCryCryMsg = "(!)" + this.m_sCharName + ": " + SC;
                                if (m_boFilterSendMsg)
                                {
                                    this.SendMsg(null, Grobal2.RM_CRY, 0, 0, 0xFFFF, 0, sCryCryMsg);
                                }
                                else
                                {
                                    M2Share.UserEngine.CryCry(Grobal2.RM_CRY, this.m_PEnvir, this.m_nCurrX, this.m_nCurrY, 50, M2Share.g_Config.btCryMsgFColor,
                                        M2Share.g_Config.btCryMsgBColor, sCryCryMsg);
                                }
                                return;
                            }
                            this.SysMsg(string.Format(GameMsgDef.g_sYouCanSendCyCyLaterMsg, 10 - (HUtil32.GetTickCount() - m_dwShoutMsgTick) / 1000), TMsgColor.c_Red, TMsgType.t_Hint);
                            return;
                        }
                        // '本地图不允许喊话！！！'
                        this.SysMsg(GameMsgDef.g_sThisMapDisableSendCyCyMsg, TMsgColor.c_Red, TMsgType.t_Hint);
                        return;
                    }
                    if (m_boFilterSendMsg)
                    {
                        // 如果禁止发信息，则只向自己发信息
                        // g_Config.btHearMsgFColor
                        this.SendMsg(this, Grobal2.RM_HEAR, 0, m_btHearMsgFColor, M2Share.g_Config.btHearMsgBColor, 0, this.m_sCharName + ":" + sData);
                    }
                    else
                    {
                        this.SendRefMsg(Grobal2.RM_HEAR, 0, m_btHearMsgFColor, M2Share.g_Config.btHearMsgBColor, 0, this.m_sCharName + ":" + sData);
                    }
                    return;
                }
                // '禁止聊天'
                this.SysMsg(GameMsgDef.g_sYouIsDisableSendMsg, TMsgColor.c_Red, TMsgType.t_Hint);
            }
            catch
            {
                M2Share.MainOutMessage(string.Format(sExceptionMsg, sData));
            }
        }

        /// <summary>
        /// 人物掉落装备物品
        /// </summary>
        /// <param name="BaseObject"></param>
        public override void DropUseItems(TBaseObject BaseObject)
        {
            int nRate;
            TStdItem StdItem;
            List<string> DelList = null;
            byte nCode = 0;
            const string sExceptionMsg = "[异常] TPlayObject::DropUseItems Code:";
            m_boCanQueryBag = true;// 掉落装备物品时,不能刷新包裹
            try
            {
                try
                {
                    if (this.m_PEnvir.m_boNODROPITEM) // 地图禁止死亡掉物品则退出
                    {
                        return;
                    }
                    nCode = 1;
                    if (this.m_boAngryRing || this.m_boNoDropUseItem)
                    {
                        return;
                    }
                    nCode = 2;
                    for (int i = m_UseItems.GetLowerBound(0); i <= m_UseItems.GetUpperBound(0); i++)
                    {
                        nCode = 3;
                        if (this.m_UseItems[i] == null)
                        {
                            continue;
                        }
                        StdItem = M2Share.UserEngine.GetStdItem(this.m_UseItems[i].wIndex);
                        nCode = 4;
                        if (StdItem != null)
                        {

                            nCode = 5;
                            if (this.CheckItemValue(this.m_UseItems[i], 5)) // 禁止爆出
                            {
                                continue;
                            }
                            if (this.PlugOfCheckCanItem(6, StdItem.Name, false, 0, 0)) // 禁止物品规则(永不爆出)
                            {
                                continue;
                            }
                            if (CheckItemBindDieNoDrop(this.m_UseItems[i]))// 人物装备绑定死亡不爆
                            {
                                continue;
                            }

                            nCode = 7;
                            if (Convert.ToInt32(StdItem.Reserved & 8) != 0)
                            {
                                nCode = 8;
                                if (DelList == null)
                                {
                                    DelList = new List<string>();
                                }
                                nCode = 9;
                                // DelList.AddObject('', TObject(m_UseItems[i].MakeIndex));
                                if (this.m_UseItems[i].wIndex > 0)//增加
                                {
                                    //DelList.Add(M2Share.UserEngine.GetStdItemName(this.m_UseItems[i].wIndex), ((this.m_UseItems[i].MakeIndex) as Object));
                                }
                                nCode = 18;
                                if (StdItem.NeedIdentify == 1)
                                {
                                    M2Share.AddGameDataLog("16" + "\09" + this.m_sMapName + "(" + (this.m_btRaceServer).ToString() + ")" + "\09"
                                        + (this.m_nCurrX).ToString() + "\09" + (this.m_nCurrY).ToString() + "\09" + this.m_sCharName + "\09" +
                                        StdItem.Name + "\09" + (this.m_UseItems[i].MakeIndex).ToString() + "\09" + "(" + (HUtil32.LoWord(StdItem.DC)).ToString() +
                                        "/" + (HUtil32.HiWord(StdItem.DC)).ToString() + ")" + "(" + (HUtil32.LoWord(StdItem.MC)).ToString() + "/" + (HUtil32.HiWord(StdItem.MC)).ToString() + ")" +
                                        "(" + (HUtil32.LoWord(StdItem.SC)).ToString() + "/" + (HUtil32.HiWord(StdItem.SC)).ToString() + ")" + "(" + (HUtil32.LoWord(StdItem.AC)).ToString() + "/"
                                        + (HUtil32.HiWord(StdItem.AC)).ToString() + ")" + "(" + (HUtil32.LoWord(StdItem.MAC)).ToString() + "/" + (HUtil32.HiWord(StdItem.MAC)).ToString() + ")" +
                                        (this.m_UseItems[i].btValue[0]).ToString() + "/" + (this.m_UseItems[i].btValue[1]).ToString() + "/" + (this.m_UseItems[i].btValue[2]).ToString()
                                        + "/" + (this.m_UseItems[i].btValue[3]).ToString() + "/" + (this.m_UseItems[i].btValue[4]).ToString() + "/" +
                                        (this.m_UseItems[i].btValue[5]).ToString() + "/" + (this.m_UseItems[i].btValue[6]).ToString() + "/" + (this.m_UseItems[i].btValue[7]).ToString()
                                        + "/" + (this.m_UseItems[i].btValue[8]).ToString() + "/" + (this.m_UseItems[i].btValue[14]).ToString() + "\09" + "0");
                                }
                                nCode = 19;
                                if (StdItem.Shape >= 126 && StdItem.Shape <= 129)// 祈祷装备,被怪(不是宝宝)打死,装备才消失,其它打死不消失
                                {
                                    nCode = 20;
                                    if (this.m_LastHiter != null)
                                    {
                                        nCode = 21;
                                        if ((this.m_LastHiter.m_btRaceServer != Grobal2.RC_PLAYOBJECT) && (this.m_LastHiter.m_Master == null))
                                        {
                                            this.m_UseItems[i].wIndex = 0;
                                        }
                                        else
                                        {
                                            continue;
                                        }
                                    }
                                }
                                else
                                {
                                    this.m_UseItems[i].wIndex = 0;
                                }
                            }
                        }
                    }
                    nCode = 10;
                    if (this.PKLevel() > 2)// 15
                    {

                        nRate = M2Share.g_Config.nDieRedDropUseItemRate;
                    }
                    else // 30
                    {
                        nRate = M2Share.g_Config.nDieDropUseItemRate;
                    }
                    nCode = 11;
                    for (int i = m_UseItems.GetLowerBound(0); i <= m_UseItems.GetUpperBound(0); i++)
                    {
                        nCode = 12;
                        if (HUtil32.Random(nRate) != 0 || this.m_UseItems[i] == null)
                        {
                            continue;
                        }
                        StdItem = M2Share.UserEngine.GetStdItem(this.m_UseItems[i].wIndex);
                        nCode = 13;
                        if (M2Share.InDisableTakeOffList(this.m_UseItems[i].wIndex))   // 检查是否在禁止取下列表,如果在列表中则不掉此物品
                        {
                            continue;
                        }
                        if (this.CheckItemValue(this.m_UseItems[i], 5))// 禁止爆出
                        {
                            continue;
                        }
                        if (StdItem != null)
                        {
                            if (this.PlugOfCheckCanItem(6, StdItem.Name, false, 0, 0))// 禁止物品规则(永不爆出)
                            {
                                continue;
                            }
                        }
                        if (CheckItemBindDieNoDrop(this.m_UseItems[i]))    // 人物装备绑定死亡不爆
                        {
                            continue;
                        }
                        nCode = 15;
                        if (this.DropItemDown(this.m_UseItems[i], 3, true, true, BaseObject, this)) // 爆出装备
                        {
                            nCode = 16;
                            if (StdItem != null)
                            {
                                if (Convert.ToInt32(StdItem.Reserved & 10) == 0)
                                {
                                    if (this.m_btRaceServer == Grobal2.RC_PLAYOBJECT)
                                    {
                                        nCode = 17;
                                        if (DelList == null)
                                        {
                                            DelList = new List<string>();
                                        }
                                        //DelList.Add(M2Share.UserEngine.GetStdItemName(this.m_UseItems[i].wIndex), ((this.m_UseItems[i].MakeIndex) as Object));
                                    }
                                    this.m_UseItems[i].wIndex = 0;
                                }
                            }
                        }
                    }
                    if (DelList != null)
                    {
                        Console.WriteLine("todo RM_SENDDELITEMLIST...");
                        //this.SendMsg(this, Grobal2.RM_SENDDELITEMLIST, 0, DelList.ToInt(), 0, 0, "");
                    }
                }
                catch
                {
                    M2Share.MainOutMessage(sExceptionMsg + nCode);
                }
            }
            finally
            {
                m_boCanQueryBag = false;// 掉落装备物品时,不能刷新包裹
            }
        }


        public override void SearchViewRange()
        {
            int nIdx;
            int n24 = 0;
            MapCellInfo MapCellInfo;
            TOSObject OSObject;
            TBaseObject BaseObject;
            TMapItem MapItem;
            TEvent MapEvent;
            TVisibleMapEvent VisibleMapEvent;
            TVisibleBaseObject VisibleBaseObject;
            TVisibleMapItem VisibleMapItem;
            byte nCheckCode = 1;
            byte btType;
            int nVisibleFlag;
            const string sExceptionMsg1 = "[异常] TPlayObject::SearchViewRange Code:{0}";
            const string sExceptionMsg2 = "[异常] TPlayObject::SearchViewRange 1-{0} {1} {2} {3} {4} {5}";
            try
            {
                if (m_boNotOnlineAddExp || this.m_boDeath || this.m_boGhost)//离线挂机不搜索,死亡也不搜索
                {
                    return;
                }
                nCheckCode = 2;
                if (this.m_VisibleItems.Count > 0)
                {
                    for (var i = 0; i < this.m_VisibleItems.Count; i++)
                    {
                        this.m_VisibleItems[i].nVisibleFlag = 0;
                    }
                }
                nCheckCode = 3;
                if (this.m_VisibleEvents.Count > 0)
                {
                    for (var i = 0; i < this.m_VisibleEvents.Count; i++)
                    {
                        this.m_VisibleEvents[i].nVisibleFlag = 0;
                    }
                }
                nCheckCode = 4;
                if (this.m_VisibleActors.Count > 0)
                {
                    for (var i = 0; i < this.m_VisibleActors.Count; i++)
                    {
                        this.m_VisibleActors[i].nVisibleFlag = 0;
                    }
                }
            }
            catch
            {
                M2Share.MainOutMessage(string.Format(sExceptionMsg1, nCheckCode));
                this.KickException();
            }
            nCheckCode = 6;
            try
            {
                var nStartX = this.m_nCurrX - this.m_nViewRange;
                var nEndX = this.m_nCurrX + this.m_nViewRange;
                var nStartY = this.m_nCurrY - this.m_nViewRange;
                var nEndY = this.m_nCurrY + this.m_nViewRange;
                nCheckCode = 7;
                for (var n18 = nStartX; n18 <= nEndX; n18++)
                {
                    for (var n1C = nStartY; n1C <= nEndY; n1C++)
                    {
                        nCheckCode = 8;
                        bool success = false;
                        MapCellInfo = this.m_PEnvir.GetMapCellInfo(n18, n1C, ref success);
                        if (success && (MapCellInfo.ObjList != null))
                        {
                            nCheckCode = 9;
                            n24 = 1;
                            nIdx = 0;
                            while (true)
                            {
                                if (MapCellInfo.ObjList != null)
                                {
                                    if ((MapCellInfo.ObjList != null) && (MapCellInfo.ObjList.Count <= 0))
                                    {
                                        nCheckCode = 10;
                                        MapCellInfo.ObjList = null;
                                        this.m_PEnvir.UpdateMapCellInfo(n18, n1C, MapCellInfo);
                                        nCheckCode = 101;
                                        break;
                                    }
                                }
                                nCheckCode = 11;
                                if (MapCellInfo.ObjList.Count <= nIdx)
                                {
                                    break;
                                }
                                nCheckCode = 121;
                                OSObject = MapCellInfo.ObjList[nIdx];
                                nCheckCode = 123;
                                if (OSObject != null)
                                {
                                    nCheckCode = 0;
                                    try
                                    {
                                        btType = OSObject.btType;//防止内存出错
                                    }
                                    catch
                                    {
                                        nCheckCode = 124;
                                        MapCellInfo.ObjList.RemoveAt(nIdx);
                                        nCheckCode = 125;
                                        if (MapCellInfo.ObjList.Count > 0)
                                        {
                                            continue;
                                        }
                                        nCheckCode = 126;
                                        MapCellInfo.ObjList = null;
                                        this.m_PEnvir.UpdateMapCellInfo(n18, n1C, MapCellInfo);
                                        break;
                                    }
                                    nCheckCode = 127;
                                    if (btType == Grobal2.OS_MOVINGOBJECT)
                                    {
                                        nCheckCode = 13;
                                        if ((HUtil32.GetTickCount() - OSObject.dwAddTime) >= 60000)// 60 * 1000
                                        {
                                            Dispose(OSObject);
                                            OSObject = null;
                                            MapCellInfo.ObjList.RemoveAt(nIdx);
                                            if (MapCellInfo.ObjList.Count <= 0)
                                            {
                                                MapCellInfo.ObjList = null;
                                                this.m_PEnvir.UpdateMapCellInfo(n18, n1C, MapCellInfo);
                                                break;
                                            }
                                            continue;
                                        }
                                        nCheckCode = 14;
                                        BaseObject = (TBaseObject)OSObject.CellObj;
                                        if (BaseObject != null)
                                        {
                                            if (BaseObject == this) //By John 2012.10.15 增加 如果人物坐标与地图信息坐标不一致,则删除信息
                                            {
                                                if ((this.m_nCurrX == n18) && (this.m_nCurrY == n1C))
                                                {
                                                    OSObject.dwAddTime = HUtil32.GetTickCount();
                                                    this.m_dwVerifyTick = HUtil32.GetTickCount();
                                                }
                                                else
                                                {
                                                    Dispose(OSObject);
                                                    MapCellInfo.ObjList.RemoveAt(nIdx);
                                                    if (MapCellInfo.ObjList.Count <= 0)
                                                    {
                                                        MapCellInfo.ObjList = null;
                                                        this.m_PEnvir.UpdateMapCellInfo(n18, n1C, MapCellInfo);
                                                        break;
                                                    }
                                                    continue;
                                                }
                                            }

                                            nCheckCode = 141;
                                            if (!BaseObject.m_boGhost && !BaseObject.m_boFixedHideMode && !BaseObject.m_boObMode)
                                            {
                                                nCheckCode = 15;
                                                if ((this.m_btRaceServer < Grobal2.RC_ANIMAL) || (this.m_Master != null) || this.m_boCrazyMode || this.m_boWantRefMsg
                                                    || ((BaseObject.m_Master != null) && (Math.Abs(BaseObject.m_nCurrX - this.m_nCurrX) <= 7) && (Math.Abs(BaseObject.m_nCurrY - this.m_nCurrY) <= 7))
                                                    || (BaseObject.m_btRaceServer == Grobal2.RC_PLAYOBJECT))
                                                {
                                                    nCheckCode = 16;
                                                    this.UpdateVisibleGay(BaseObject);
                                                }
                                            }
                                        }
                                    }
                                    if (this.m_btRaceServer == Grobal2.RC_PLAYOBJECT)
                                    {
                                        if ((OSObject != null))
                                        {
                                            if ((OSObject.btType == Grobal2.OS_ITEMOBJECT))
                                            {
                                                nCheckCode = 17;
                                                if ((HUtil32.GetTickCount() - OSObject.dwAddTime) > M2Share.g_Config.dwClearDropOnFloorItemTime) // 60 * 60 * 1000
                                                {
                                                    nCheckCode = 18;
                                                    if (OSObject.CellObj != null)
                                                    {
                                                        Dispose(OSObject.CellObj);
                                                        OSObject.CellObj = null;// 防止占用内存不释放现象
                                                    }
                                                    nCheckCode = 193;
                                                    if (OSObject != null)
                                                    {
                                                        nCheckCode = 192;
                                                        Dispose(OSObject);
                                                        OSObject = null;
                                                    }
                                                    nCheckCode = 20;
                                                    MapCellInfo.ObjList.RemoveAt(nIdx);
                                                    nCheckCode = 21;
                                                    if (MapCellInfo.ObjList.Count <= 0)
                                                    {
                                                        MapCellInfo.ObjList = null;
                                                        this.m_PEnvir.UpdateMapCellInfo(n18, n1C, MapCellInfo);
                                                        break;
                                                    }
                                                    continue;
                                                }
                                                MapItem = (TMapItem)OSObject.CellObj;
                                                nCheckCode = 22;
                                                this.UpdateVisibleItem(n18, n1C, MapItem);
                                                if ((MapItem.OfBaseObject != null) || (MapItem.DropBaseObject != null))
                                                {
                                                    if ((HUtil32.GetTickCount() - MapItem.dwCanPickUpTick) > M2Share.g_Config.dwFloorItemCanPickUpTime)// 2 * 60 * 1000
                                                    {
                                                        MapItem.OfBaseObject = null;
                                                        MapItem.DropBaseObject = null;
                                                    }
                                                    else
                                                    {
                                                        nCheckCode = 23;
                                                        if (((MapItem.OfBaseObject) as TBaseObject) != null)
                                                        {
                                                            if (((MapItem.OfBaseObject) as TBaseObject).m_boGhost)
                                                            {
                                                                MapItem.OfBaseObject = null;
                                                            }
                                                        }
                                                        if (((MapItem.DropBaseObject) as TBaseObject) != null)
                                                        {
                                                            if (((MapItem.DropBaseObject) as TBaseObject).m_boGhost)
                                                            {
                                                                MapItem.DropBaseObject = null;
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                        if ((OSObject != null))
                                        {
                                            if ((OSObject.btType == Grobal2.OS_EVENTOBJECT))
                                            {
                                                nCheckCode = 24;
                                                if (OSObject.CellObj != null)
                                                {
                                                    MapEvent = (TEvent)OSObject.CellObj;
                                                    if (MapEvent.m_boVisible)
                                                    {
                                                        nCheckCode = 25;
                                                        this.UpdateVisibleEvent(n18, n1C, MapEvent);
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                                nIdx++;
                            }
                        }
                    }
                }
            }
            catch
            {
                M2Share.MainOutMessage(string.Format(sExceptionMsg2, n24, this.m_sCharName, this.m_sMapName, this.m_nCurrX, this.m_nCurrY, nCheckCode));
                this.KickException();
            }
            nCheckCode = 26;
            n24 = 2;
            try
            {
                var n18 = 0;
                while (true)
                {
                    if (this.m_VisibleActors.Count <= n18)
                    {
                        break;
                    }
                    nCheckCode = 27;
                    VisibleBaseObject = this.m_VisibleActors[n18];
                    nCheckCode = 28;
                    try
                    {
                        nVisibleFlag = VisibleBaseObject.nVisibleFlag;//防止内存出错
                    }
                    catch
                    {
                        this.m_VisibleActors.RemoveAt(n18);
                        continue;
                    }
                    if (VisibleBaseObject.nVisibleFlag == 0)
                    {
                        if (this.m_btRaceServer == Grobal2.RC_PLAYOBJECT)
                        {
                            nCheckCode = 29;
                            BaseObject = VisibleBaseObject.BaseObject;
                            nCheckCode = 30;
                            if (BaseObject != null)
                            {
                                if (!BaseObject.m_boFixedHideMode && (!BaseObject.m_boGhost)) //防止人物退出时发送重复的消息占用带宽，人物进入隐身模式时人物不消失问题
                                {
                                    nCheckCode = 31;
                                    this.SendMsg(BaseObject, Grobal2.RM_DISAPPEAR, 0, 0, 0, 0, "");
                                }
                            }
                        }
                        this.m_VisibleActors.RemoveAt(n18);
                        nCheckCode = 32;
                        Dispose(VisibleBaseObject);
                        VisibleBaseObject = null;
                        continue;
                    }
                    nCheckCode = 33;
                    if ((this.m_btRaceServer == Grobal2.RC_PLAYOBJECT) && (VisibleBaseObject.nVisibleFlag == 2))
                    {
                        nCheckCode = 34;
                        BaseObject = VisibleBaseObject.BaseObject;
                        if ((BaseObject != null))
                        {
                            if ((BaseObject != this))
                            {
                                if (!BaseObject.m_boGhost)
                                {
                                    if (BaseObject.m_boDeath)
                                    {
                                        if (BaseObject.m_boSkeleton)
                                        {
                                            nCheckCode = 35;
                                            this.SendMsg(BaseObject, Grobal2.RM_SKELETON, BaseObject.m_btDirection, BaseObject.m_nCurrX, BaseObject.m_nCurrY, 0, "");
                                        }
                                        else
                                        {
                                            nCheckCode = 36;
                                            this.SendMsg(BaseObject, Grobal2.RM_DEATH, BaseObject.m_btDirection, BaseObject.m_nCurrX, BaseObject.m_nCurrY, 0, "");
                                        }
                                    }
                                    else
                                    {
                                        nCheckCode = 37;
                                        this.SendMsg(BaseObject, Grobal2.RM_TURN, BaseObject.m_btDirection, BaseObject.m_nCurrX, BaseObject.m_nCurrY, 0, BaseObject.GetShowName());
                                        nCheckCode = 38;
                                        if ((BaseObject.m_btRaceServer == Grobal2.RC_PLAYOBJECT))
                                        {
                                            nCheckCode = 39;
                                            if (((BaseObject) as TPlayObject).m_boTrainingNG)
                                            {
                                                this.SendMsg(BaseObject, Grobal2.RM_MAGIC69SKILLNH, 0, ((BaseObject) as TPlayObject).m_Skill69NH, ((BaseObject) as TPlayObject).m_Skill69MaxNH, 0, "");
                                            }
                                        }
                                        else if ((BaseObject.m_btRaceServer == Grobal2.RC_HEROOBJECT))
                                        {
                                            nCheckCode = 41;
                                            if (((THeroObject)(BaseObject)).m_boTrainingNG)
                                            {
                                                this.SendMsg(BaseObject, Grobal2.RM_MAGIC69SKILLNH, 0, ((THeroObject)(BaseObject)).m_Skill69NH, ((THeroObject)(BaseObject)).m_Skill69MaxNH, 0, "");
                                            }
                                        }
                                        else if ((BaseObject.m_btRaceServer == Grobal2.RC_PLAYMOSTER) && (BaseObject.m_Master != null))
                                        {
                                            // 学过内功人物的分身也显示黄条值
                                            if ((BaseObject.m_Master.m_btRaceServer == Grobal2.RC_PLAYOBJECT))
                                            {
                                                if (((BaseObject.m_Master) as TPlayObject).m_boTrainingNG)
                                                {
                                                    nCheckCode = 42;
                                                    this.SendMsg(BaseObject, Grobal2.RM_MAGIC69SKILLNH, 0, ((BaseObject.m_Master) as TPlayObject).m_Skill69NH,
                                                        ((BaseObject.m_Master) as TPlayObject).m_Skill69MaxNH, 0, "");
                                                }
                                            }
                                            else if ((BaseObject.m_Master.m_btRaceServer == Grobal2.RC_HEROOBJECT))
                                            {
                                                if (((THeroObject)(BaseObject.m_Master)).m_boTrainingNG)
                                                {
                                                    nCheckCode = 43;
                                                    this.SendMsg(BaseObject, Grobal2.RM_MAGIC69SKILLNH, 0, ((THeroObject)(BaseObject.m_Master)).m_Skill69NH,
                                                        ((THeroObject)(BaseObject.m_Master)).m_Skill69MaxNH, 0, "");
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    n18++;
                }
            }
            catch
            {
                M2Share.MainOutMessage(string.Format(sExceptionMsg2, n24, this.m_sCharName, this.m_sMapName, this.m_nCurrX, this.m_nCurrY, nCheckCode));
                this.KickException();
            }
            try
            {
                var i = 0;
                while (true)
                {
                    if (this.m_VisibleItems.Count <= i)
                    {
                        break;
                    }
                    VisibleMapItem = this.m_VisibleItems[i];
                    try
                    {
                        nVisibleFlag = VisibleMapItem.nVisibleFlag;//防止内存出错
                    }
                    catch
                    {
                        this.m_VisibleItems.RemoveAt(i);
                        continue;
                    }
                    nCheckCode = 38;
                    if (VisibleMapItem.nVisibleFlag == 0)
                    {
                        nCheckCode = 39;
                        this.SendMsg(this, Grobal2.RM_ITEMHIDE, 0, VisibleMapItem.MapItem.ItemId, VisibleMapItem.nX, VisibleMapItem.nY, "");
                        nCheckCode = 40;
                        this.m_VisibleItems.RemoveAt(i);
                        nCheckCode = 41;
                        try
                        {
                            Dispose(VisibleMapItem);
                            VisibleMapItem = null;
                        }
                        catch
                        {
                            VisibleMapItem = null;
                        }
                        continue;
                    }
                    nCheckCode = 42;
                    if (VisibleMapItem.nVisibleFlag == 2)
                    {
                        this.SendMsg(this, Grobal2.RM_ITEMSHOW, VisibleMapItem.wLooks, VisibleMapItem.MapItem.ItemId, VisibleMapItem.nX, VisibleMapItem.nY, VisibleMapItem.sName);
                    }
                    i++;
                }
                i = 0;
                while (true)
                {
                    if (this.m_VisibleEvents.Count <= i)
                    {
                        break;
                    }
                    nCheckCode = 43;
                    VisibleMapEvent = this.m_VisibleEvents[i];
                    try
                    {
                        nVisibleFlag = VisibleMapEvent.nVisibleFlag;
                    }
                    catch
                    {
                        this.m_VisibleEvents.RemoveAt(i);
                        continue;
                    }
                    nCheckCode = 44;
                    if (VisibleMapEvent.nVisibleFlag == 0)
                    {
                        nCheckCode = 45;
                        this.SendMsg(this, Grobal2.RM_HIDEEVENT, 0, VisibleMapEvent.MapEvent.EventId, VisibleMapEvent.nX, VisibleMapEvent.nY, "");
                        nCheckCode = 46;
                        this.m_VisibleEvents.RemoveAt(i);
                        nCheckCode = 47;
                        if (VisibleMapEvent != null)
                        {
                            Dispose(VisibleMapEvent);
                            VisibleMapEvent = null;
                        }
                        continue;
                    }
                    nCheckCode = 48;
                    if (VisibleMapEvent.nVisibleFlag == 2)
                    {
                        this.SendMsg(this, Grobal2.RM_SHOWEVENT, VisibleMapEvent.MapEvent.m_nEventType, VisibleMapEvent.MapEvent.EventId,
                            HUtil32.MakeLong(VisibleMapEvent.nX, VisibleMapEvent.MapEvent.m_nEventParam), VisibleMapEvent.nY, "");
                    }
                    i++;
                }
            }
            catch
            {
                M2Share.MainOutMessage(this.m_sCharName + "," + this.m_sMapName + "," + this.m_nCurrX + "," + this.m_nCurrY + ","
                    + " SearchViewRange 3 CheckCode:" + nCheckCode);
                this.KickException();
            }
        }

        /// <summary>
        /// 人物下线或者死亡
        /// </summary>
        public override void MakeGhost()
        {
            string sSayMsg;
            TPlayObject Human;
            const string sExceptionMsg = "[异常] TPlayObject::MakeGhost";
            try
            {
                if ((M2Share.g_HighLevelHuman == this))
                {
                    M2Share.g_HighLevelHuman = null;
                }
                if ((M2Share.g_HighPKPointHuman == this))
                {
                    M2Share.g_HighPKPointHuman = null;
                }
                if ((M2Share.g_HighDCHuman == this))
                {
                    M2Share.g_HighDCHuman = null;
                }
                if ((M2Share.g_HighMCHuman == this))
                {
                    M2Share.g_HighMCHuman = null;
                }
                if ((M2Share.g_HighSCHuman == this))
                {
                    M2Share.g_HighSCHuman = null;
                }
                if ((M2Share.g_HighOnlineHuman == this))
                {
                    M2Share.g_HighOnlineHuman = null;
                }
                // 人物下线后通知配偶，并把对方的相关记录清空
                if (m_DearHuman != null)
                {
                    if (this.m_btGender == 0)
                    {
                        sSayMsg = GameMsgDef.g_sManLongOutDearOnlineMsg.Replace("%d", m_sDearName);
                        sSayMsg = sSayMsg.Replace("%s", this.m_sCharName);
                        sSayMsg = sSayMsg.Replace("%m", this.m_PEnvir.sMapDesc);
                        sSayMsg = sSayMsg.Replace("%x", (this.m_nCurrX).ToString());
                        sSayMsg = sSayMsg.Replace("%y", (this.m_nCurrY).ToString());
                        m_DearHuman.SysMsg(sSayMsg, TMsgColor.c_Red, TMsgType.t_Hint);
                    }
                    else
                    {
                        sSayMsg = GameMsgDef.g_sWoManLongOutDearOnlineMsg.Replace("%d", m_sDearName);
                        sSayMsg = sSayMsg.Replace("%s", this.m_sCharName);
                        sSayMsg = sSayMsg.Replace("%m", this.m_PEnvir.sMapDesc);
                        sSayMsg = sSayMsg.Replace("%x", (this.m_nCurrX).ToString());
                        sSayMsg = sSayMsg.Replace("%y", (this.m_nCurrY).ToString());
                        m_DearHuman.SysMsg(sSayMsg, TMsgColor.c_Red, TMsgType.t_Hint);
                    }
                    m_DearHuman.m_DearHuman = null;
                    m_DearHuman = null;
                }
                if ((m_MasterHuman != null) || (m_MasterList.Count > 0))
                {
                    if (m_boMaster)
                    {
                        if (m_MasterList.Count > 0)
                        {
                            for (int i = 0; i < m_MasterList.Count; i++)
                            {
                                Human = ((m_MasterList[i]) as TPlayObject);
                                sSayMsg = GameMsgDef.g_sMasterLongOutMasterListOnlineMsg.Replace("%s", this.m_sCharName);
                                sSayMsg = sSayMsg.Replace("%m", this.m_PEnvir.sMapDesc);
                                sSayMsg = sSayMsg.Replace("%x", (this.m_nCurrX).ToString());
                                sSayMsg = sSayMsg.Replace("%y", (this.m_nCurrY).ToString());
                                Human.SysMsg(sSayMsg, TMsgColor.c_Red, TMsgType.t_Hint);
                                Human.m_MasterHuman = null;
                            }
                        }
                    }
                    else
                    {
                        if (m_MasterHuman == null)
                        {
                            return;
                        }
                        sSayMsg = GameMsgDef.g_sMasterListLongOutMasterOnlineMsg.Replace("%d", this.MoneyToCharacter(m_nMasterNo));
                        sSayMsg = sSayMsg.Replace("%s", this.m_sCharName);
                        sSayMsg = sSayMsg.Replace("%m", this.m_PEnvir.sMapDesc);
                        sSayMsg = sSayMsg.Replace("%x", (this.m_nCurrX).ToString());
                        sSayMsg = sSayMsg.Replace("%y", (this.m_nCurrY).ToString());
                        m_MasterHuman.SysMsg(sSayMsg, TMsgColor.c_Red, TMsgType.t_Hint);// 如果为大徒弟则将对方的记录清空
                        if (m_MasterHuman.m_sMasterName == this.m_sCharName)
                        {
                            m_MasterHuman.m_MasterHuman = null;
                        }
                        for (int i = m_MasterHuman.m_MasterList.Count - 1; i >= 0; i--)
                        {
                            if (m_MasterHuman.m_MasterList.Count <= 0)
                            {
                                break;
                            }
                            if (m_MasterHuman.m_MasterList[i] == this)
                            {
                                m_MasterHuman.m_MasterList.RemoveAt(i);
                                break;
                            }
                        }
                    }
                }
            }
            catch
            {
                M2Share.MainOutMessage(sExceptionMsg);
                // MainOutMessage(E.Message);
            }
            base.MakeGhost();
        }

        public override void Disappear()
        {
            if (m_boReadyRun)
            {
                this.DisappearA();
            }
            if (this.m_boTransparent && this.m_boHideMode)
            {
                this.m_wStatusTimeArr[Grobal2.STATE_TRANSPARENT] = 0;
            }
            if (m_GroupOwner != null)
            {
                m_GroupOwner.DelMember(this);
            }
            if (this.m_MyGuild != null)
            {
                this.m_MyGuild.DelHumanObj(this);
            }
            LogonTimcCost();
            base.Disappear();
        }

        /// <summary>
        /// 发送消息
        /// </summary>
        public unsafe virtual void SendSocket(TDefaultMessage m_DefMsg, string sMsg)
        {
            TMsgHeader MsgHdr;
            int nSendBytes;
            byte[] Buff = null;
            TDefaultMessage* DefMsg = &m_DefMsg;
            const string sExceptionMsg = "[异常] TPlayObject::SendSocket..";
            try
            {
                MsgHdr = new TMsgHeader
                {
                    dwCode = Grobal2.RUNGATECODE,
                    nSocket = m_nSocket,
                    wGSocketIdx = (short)m_nGSocketIdx,
                    wIdent = Common.GM_DATA
                };
                if (DefMsg != null)
                {
                    if (sMsg != "")
                    {
                        byte[] bMsg = HUtil32.StringToByteAry(sMsg);
                        MsgHdr.nLength = bMsg.Length + sizeof(TDefaultMessage) + 1;
                        nSendBytes = MsgHdr.nLength + sizeof(TMsgHeader);
                        Buff = new byte[nSendBytes + sizeof(int)];
                        fixed (byte* pb = Buff)
                        {
                            *(int*)pb = nSendBytes;
                            *(TMsgHeader*)(pb + sizeof(int)) = MsgHdr;
                            *(TDefaultMessage*)(pb + sizeof(int) + sizeof(TMsgHeader)) = *DefMsg;
                            Array.Copy(bMsg, 0, Buff, sizeof(TDefaultMessage) + sizeof(TMsgHeader) + sizeof(int), bMsg.Length);
                            Buff[Buff.Length - 1] = 0;
                        }
                    }
                    else
                    {
                        MsgHdr.nLength = sizeof(TDefaultMessage);
                        nSendBytes = MsgHdr.nLength + sizeof(TMsgHeader);
                        Buff = new byte[nSendBytes + sizeof(int)];
                        fixed (byte* pb = Buff)
                        {
                            *(int*)pb = nSendBytes;
                            *(TMsgHeader*)(pb + sizeof(int)) = MsgHdr;
                            *(TDefaultMessage*)(pb + sizeof(int) + sizeof(TMsgHeader)) = *DefMsg;
                        }
                    }
                }
                else
                {
                    if (sMsg != "")
                    {
                        byte[] bMsg = HUtil32.StringToByteAry(sMsg);
                        MsgHdr.nLength = -(bMsg.Length + 1);
                        nSendBytes = Math.Abs(MsgHdr.nLength) + sizeof(TMsgHeader);
                        Buff = new byte[nSendBytes + sizeof(int)];
                        fixed (byte* pb = Buff)
                        {
                            *(int*)pb = nSendBytes;
                            *(TMsgHeader*)(pb + sizeof(int)) = MsgHdr;
                            Array.Copy(bMsg, 0, Buff, sizeof(TMsgHeader) + sizeof(int), bMsg.Length);
                            Buff[Buff.Length - 1] = 0;
                        }
                    }
                }
                if (!M2Share.RunSocket.AddGateBuffer(m_nGateIdx, Buff))
                {
                    Dispose(Buff);
                    Buff = null;
                }
            }
            catch
            {
                M2Share.MainOutMessage(sExceptionMsg);
            }
        }

        /// <summary>
        /// 发送消息
        /// </summary>
        public unsafe virtual void SendSocket(TDefaultMessage* DefMsg, string sMsg)
        {
            TMsgHeader MsgHdr;
            int nSendBytes;
            byte[] Buff = null;
            const string sExceptionMsg = "[异常] TPlayObject::SendSocket..";
            try
            {
                MsgHdr = new TMsgHeader
                {
                    dwCode = Grobal2.RUNGATECODE,
                    nSocket = m_nSocket,
                    wGSocketIdx = (short)m_nGSocketIdx,
                    wIdent = Common.GM_DATA
                };
                if (DefMsg != null)
                {
                    if (sMsg != "")
                    {
                        byte[] bMsg = HUtil32.StringToByteAry(sMsg);
                        MsgHdr.nLength = bMsg.Length + sizeof(TDefaultMessage) + 1;
                        nSendBytes = MsgHdr.nLength + sizeof(TMsgHeader);
                        Buff = new byte[nSendBytes + sizeof(int)];
                        fixed (byte* pb = Buff)
                        {
                            *(int*)pb = nSendBytes;
                            *(TMsgHeader*)(pb + sizeof(int)) = MsgHdr;
                            *(TDefaultMessage*)(pb + sizeof(int) + sizeof(TMsgHeader)) = *DefMsg;
                            Array.Copy(bMsg, 0, Buff, sizeof(TDefaultMessage) + sizeof(TMsgHeader) + sizeof(int), bMsg.Length);
                            Buff[Buff.Length - 1] = 0;
                        }
                    }
                    else
                    {
                        MsgHdr.nLength = sizeof(TDefaultMessage);
                        nSendBytes = MsgHdr.nLength + sizeof(TMsgHeader);
                        Buff = new byte[nSendBytes + sizeof(int)];
                        fixed (byte* pb = Buff)
                        {
                            *(int*)pb = nSendBytes;
                            *(TMsgHeader*)(pb + sizeof(int)) = MsgHdr;
                            *(TDefaultMessage*)(pb + sizeof(int) + sizeof(TMsgHeader)) = *DefMsg;
                        }
                    }
                }
                else
                {
                    if (sMsg != "")
                    {
                        byte[] bMsg = HUtil32.StringToByteAry(sMsg);
                        MsgHdr.nLength = -(bMsg.Length + 1);
                        nSendBytes = Math.Abs(MsgHdr.nLength) + sizeof(TMsgHeader);
                        Buff = new byte[nSendBytes + sizeof(int)];
                        fixed (byte* pb = Buff)
                        {
                            *(int*)pb = nSendBytes;
                            *(TMsgHeader*)(pb + sizeof(int)) = MsgHdr;
                            Array.Copy(bMsg, 0, Buff, sizeof(TMsgHeader) + sizeof(int), bMsg.Length);
                            Buff[Buff.Length - 1] = 0;
                        }
                    }
                }
                if (!M2Share.RunSocket.AddGateBuffer(m_nGateIdx, Buff))
                {
                    Dispose(Buff);
                    Buff = null;
                }
            }
            catch
            {
                M2Share.MainOutMessage(sExceptionMsg);
            }
        }

        /// <summary>
        /// 发送消息
        /// </summary>
        public unsafe virtual void SendDefMessage(int wIdent, int nRecog, int nParam, int nTag, int nSeries, string sMsg)
        {
            this.m_DefMsg = EncryptUnit.MakeDefaultMsg(wIdent, nRecog, nParam, nTag, nSeries, 0);
            if (sMsg != "" && sMsg != null)
            {
                SendSocket(this.m_DefMsg, EncryptUnit.EncodeString(sMsg));
            }
            else
            {
                SendSocket(this.m_DefMsg, "");
            }
        }
    }
}